Open this lesson in your favourite AI. It'll walk you through the why, explain the demo, and quiz you on the try-it list.
Every Go program you ship goes through the same go binary — it compiles, runs, tests, formats, vets, and manages dependencies. Knowing your version, where Go is installed, and what GOPATH actually means today (almost nothing — modules replaced it as the unit of dependency management) saves hours when CI behaves differently from your laptop. Go ships meaningful language updates every 6 months: generics in 1.18, structured logging via log/slog in 1.21, range-over-int in 1.22, range-over-func in 1.23. If you're below 1.22, upgrade before writing a line of this course.
Go's toolchain is a single binary that ships with the compiler, linker, build tool, test runner, and documentation server. Installing means downloading a versioned archive and adding Go's bin/ and $GOPATH/bin to your $PATH. The first go version output tells you the exact toolchain, including the commit hash, which matters because Go's backward-compatibility guarantee only applies within the same major version. In modern Go (1.11+), you almost never need to worry about GOPATH for your own code — modules handle dependency tracking separately.
go version. If older than 1.22, upgrade — many demos in this course use log/slog and range-over-int.go env GOROOT GOPATH and identify each: GOROOT is where Go itself is installed; GOPATH is where go install writes binaries.$(go env GOPATH)/bin to your shell PATH. Tools like goimports, gopls, staticcheck install there and need to be on PATH to be useful.go help build. The CLI is self-documenting — this is your first stop before searching online.Use these three in order. Each builds on the one before.
In one paragraph, explain what the `go` command actually is — compiler, build tool, package manager, or all three? And what does GOPATH mean in 2026 vs 2017?
Walk me through what happens when I run `go run main.go`: where does it compile to, what's the build cache about, why is it slower than `go build` followed by running the binary directly?
I need three different Go versions on one machine for different projects. Compare `gvm`, `asdf-golang`, and the `go install golang.org/dl/go1.21@latest` approach — which is cleanest in 2026 and why?
# macOS:
brew install go
# Linux: prefer the official tarball over apt — distro packages lag.
# https://go.dev/dl
# verify:
$ go version
go version go1.22.5 darwin/arm64
$ go env GOROOT GOPATH GOOS GOARCH
/opt/homebrew/Cellar/go/1.22.5/libexec
/Users/you/go
darwin
arm64go run main.go