Go | The School of Code

Settings

Appearance

Choose a typography theme that suits your style

Go

Learn concurrent programming with Go.

1

Hello World

Go uses fmt.Println() for output. Every file starts with a package declaration.

Example

Run this example to see how it works and then try the exercise.

example.go
Loading...
Output
Click "Run" to see the example in action...
Exercise

Your task: Print "Hello, World!" using fmt.Println()

main.go
Loading...
Output
Click "Run" to execute your code...
Quiz

What must every Go source file start with?

SUMMARY

In this section, you learned how to print output to the console. Next, you'll learn how to declare variables.

2

Variables

Go offers two ways to declare variables: var for explicit typing and := for short declaration.

Example

Run this example to see how it works and then try the exercise.

example.go
Loading...
Output
Click "Run" to see the example in action...
Exercise

Your task: Declare variables name and age using :=

main.go
Loading...
Output
Click "Run" to execute your code...
Quiz

What is the short variable declaration operator in Go?

SUMMARY

In this section, you learned how to declare variables. Next, you'll learn how to perform mathematical operations.

3

Arithmetic Operations

Go supports all standard arithmetic operations. Integer division truncates the decimal part.

Example

Run this example to see how it works and then try the exercise.

example.go
Loading...
Output
Click "Run" to see the example in action...
Exercise

Your task: Calculate area and print "Area: {area}"

main.go
Loading...
Output
Click "Run" to execute your code...
Quiz

What is the result of 17 / 5 in Go (both are int)?

SUMMARY

In this section, you learned how to perform mathematical operations. Next, you'll learn how to manipulate and work with strings.

Unlock 10 More Lessons

You've completed the free preview! Upgrade to Pro to access all 12 lessons in this course, plus advanced projects and certificates.

Locked lessons:
  • String Operations
  • Functions
  • Conditionals
  • Switch Statements
  • Arrays and Slices
  • Maps
  • Structs
  • Structs
  • Final Project: Student Grade System
Hello World 1
Variables 2
Arithmetic Operations 3
Unlock 10 more lessons Access all content with Pro
Upgrade
String Operations 4 Functions 5 Conditionals 6 Switch Statements 7 Arrays and Slices 8 Maps 9 Structs 10 Structs 11 Final Project: Student Grade System 12

Reset Progress?

Are you sure you want to reset all progress for this course? This action cannot be undone.