Your First Go Program
Every runnable Go program needs two things at the top: a package main declaration, and a func main() — this is where execution starts, just like in several other compiled languages. fmt.Println comes from Go's standard fmt package, which has to be imported before you can use it.
Compiling happens first
When you hit run, the Go compiler checks your entire file before executing a single line — every type, every unused variable, every unused import. If anything's wrong, nothing runs at all: you get a build error instead of output. This is deliberately stricter than many scripting languages, and it's part of what makes Go programs reliable.
Comments
Comments work like most C-family languages: anything after // on a line is ignored completely, and they exist purely so humans reading the code later understand why something is written the way it is.
Run it yourself
Here's a small program with a comment and two fmt.Println calls. This was actually executed to get the output shown below — try changing the text and running it yourself using the button under the example.
// This is a comment - Go ignores it
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
fmt.Println("Welcome to Go.")
}Hello, World! Welcome to Go.
Next: variables and types — var, :=, and Go's zero values.
Practice exercise
Add a comment above your code, then print "Learning Go one step at a time."