Installing Go
Go ships as a single, self-contained toolchain: a compiler, formatter, test runner, and dependency manager, all behind one go command. There’s no separate package manager or build system to configure.
Install the toolchain
Section titled “Install the toolchain”Pick the path for your OS:
- macOS:
brew install go, or download the.pkginstaller from go.dev/dl. - Linux: download the tarball from go.dev/dl and extract it to
/usr/local, then add/usr/local/go/binto yourPATH. - Windows: download the
.msiinstaller from go.dev/dl; it sets upPATHfor you.
Most Linux distributions also ship a golang package, but it often lags behind the latest release — the official tarball is usually the better choice for tutorials like this one.
Verify the install
Section titled “Verify the install”go versionYou should see something like go version go1.23.4 darwin/arm64. If you get “command not found”, double-check that go’s bin directory is on your PATH.
Editor setup
Section titled “Editor setup”Any editor works, but the smoothest experience is:
- VS Code with the official Go extension (gives you
gofmt,go vet, and debugging out of the box). - GoLand if you want a full IDE with more built-in refactoring tools.
Both will auto-install gopls, Go’s language server, the first time you open a .go file.
Go modules, briefly
Section titled “Go modules, briefly”Since Go 1.16, every project is a module — a tree of Go source files with a go.mod file at its root describing the module’s name and dependencies. You’ll create your first one in the next chapter.