Installing Go
Scope: getting the Go toolchain on your machine and proving it works. The toolchain is one download: compiler, build tool, and package manager together.
The short version
Download the installer for your OS from go.dev/dl and run it. That's the whole process — no separate package manager setup needed.
Windows
- Download the
.msiinstaller from go.dev/dl. - Run it, accept the defaults.
- Open a new PowerShell or Command Prompt.
Check:
go version
You should see something like go version go1.25.1 windows/amd64.
Mac
Either download the .pkg installer from
go.dev/dl, or via Homebrew:
brew install go
Check:
go version
Linux
Download the tarball from go.dev/dl and
extract it to /usr/local (the
install page has the exact commands),
or use your package manager — but distro packages can lag behind,
so the official tarball is the safer bet.
Check:
go version
The one tool, plainly
Unlike Rust's three tools, Go has one: go. It compiles,
runs, tests, formats, and fetches libraries:
| Command | Job |
|---|---|
go run |
Compile and run, in one step |
go build |
Compile to a binary file |
go mod init |
Start a new project (module) |
go fmt |
Reformat your code the standard way |
go test |
Run tests |
go get |
Add a third-party library |
GOPATH: the one thing to know
Old tutorials mention GOPATH and putting code in special
folders. Ignore them. Since Go 1.16, projects live anywhere —
go mod init marks a folder as a project (a module), and that's
all the setup there is.
Keeping it updated
Re-download from go.dev/dl when a new
version comes out (roughly twice a year), or brew upgrade go on
Mac. Check what's new only if you're curious — upgrades are
famously boring, which is a compliment.
Check
- [ ]
go versionprints a version number - [ ] You can say what
go run,go build, andgo fmtdo
Next: Your First Program.