Lesson 1 of 38 · Fundamentals
Go Hello World: Your First Go Program
Welcome to the Gopher Isles! Every Go developer's journey starts the same way: by making the computer say hello. In this lesson you will write and run a real Go program — right here in your browser, with nothing to install.
Go (often called Golang) was created at Google to make building fast, reliable software simple. It powers Docker, Kubernetes and thousands of cloud services, and its small, clean syntax makes it a great language to learn.
Your first Go program
Here is a complete Go program:
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
When you run it, it prints:
Hello, World!
It is only five lines, but each one has a job:
package main— every Go file belongs to a package. The package calledmainis special: it builds a runnable program instead of a library.import "fmt"— loads the fmt package from Go's standard library. It contains functions for formatting and printing text ("fmt" is short for format).func main() { ... }— declares the main function. This is where every Go program starts running. Whenmainfinishes, the program ends.fmt.Println("Hello, World!")— calls thePrintlnfunction from thefmtpackage. It prints its arguments followed by a newline (lnstands for line).
The text in double quotes is a string. Go strings always use double quotes "..." — single quotes mean something else in Go.
Statements run from top to bottom
Inside main, Go runs one statement after another. Each fmt.Println call prints one line:
package main
import "fmt"
func main() {
fmt.Println("Line one")
fmt.Println("Line two")
fmt.Println("Level", 1, "complete:", 2+3, "points")
}
Line one
Line two
Level 1 complete: 5 points
Println accepts several values separated by commas and prints them with a space in between. Notice that 2+3 was calculated before printing because it is not inside quotes.
There are no semicolons at the end of the lines: Go inserts them for you. The opening brace { must stay on the same line as func main() — moving it to the next line is a compile error.
Comments
Text after // is a comment: notes for humans that Go ignores. For longer notes you can use /* ... */.
// main is where the program starts.
func main() {
fmt.Println("Comments are ignored") // so is this
}
Common mistakes
- Wrong capitalisation: Go is case-sensitive.
fmt.printlndoes not exist — exported names such asPrintlnstart with a capital letter. - Single quotes for text:
'Hello'is not a string in Go. Use double quotes. - Forgetting the import: using
fmt.Printlnwithoutimport "fmt"fails withundefined: fmt. - Unused imports: the opposite mistake is also an error. Go refuses to compile a program that imports a package it never uses, which keeps code clean.
Assignment
Write a program that prints exactly these two lines:
Hello, Gopher!
Go is fun.
The output must match exactly — capital letters, spaces and punctuation all count. Run your code to see the output, then submit it to check.
Hello World in other languages
- Hello, World! Your First JavaScript Program · JavaScript
- Python Hello World: Your First Program · Python
- Java Hello World: Your First Program · Java
- C# Hello World: Your First Program · C#
Need a quick reminder? The Go cheat sheet has every topic of Learn Go on one page.
Lesson last updated on .