Introduction

Go is a compiled, statically typed language created at Google in 2009, designed around one central goal: keep large programs simple to read, fast to build, and easy for many people to work on at once.

Why Go exists

Go's designers were frustrated with how slow C++ was to compile at Google's scale, and how much ceremony languages like Java required for straightforward tasks. Go's answer is a deliberately small language — a couple dozen keywords total — with one standard formatting style (enforced by the gofmt tool, not by convention), fast compilation to a single self-contained binary, and concurrency built directly into the language rather than bolted on as a library.

Your first Go program

Every runnable Go program starts the same way: it belongs to package main, and execution begins in a function named main:

Go main.go
package main

import "fmt"

func main() {
	fmt.Println("Hello, Go!")
}
Output
Hello, Go!

package main tells the compiler this file produces a standalone executable rather than a reusable library. import "fmt" pulls in Go's standard formatting/printing package, and fmt.Println is the function inside it that writes a line to the terminal. func main() is where the program actually starts running.

Note: Go treats an unused import as a compile error, not a warning — import "fmt" without ever calling anything from fmt will refuse to build. The same is true of unused local variables. This feels strict coming from most other languages, but it's deliberate: it keeps real Go codebases free of the dead imports and forgotten variables that quietly accumulate elsewhere.

Running vs. building

go run main.go compiles and immediately runs the program in one step — convenient while you're learning or testing. go build main.go instead produces a standalone binary (main, or main.exe on Windows) that you can run on its own, with no Go installation required on the machine that runs it:

Terminal
$ go build main.go
$ ./main
Output
Hello, Go!

That single compiled binary is one of Go's most practical selling points for deployment: no separate runtime or interpreter needs to be installed alongside it, unlike Python, Java, or PHP.