Installing Go
You already know how to program. What you're missing is Go specifically —
the compiler, the standard library, and the handful of commands that turn
.go files into running programs. This lesson gets that onto your machine.
Getting the toolchain
The straightforward route is go.dev/dl, which has installers for macOS, Windows, and Linux. If you'd rather use a package manager, that works too:
brew install go # macOS (Homebrew)
sudo apt install golang-go # Debian/Ubuntu
choco install golang # Windows (Chocolatey)
Any of these gets you the same thing: the go binary, plus the standard
library it ships with.
Confirming it works
Open a terminal and check the version:
go version
# go version go1.25.0 darwin/arm64
If that prints a version number, you're set up correctly. If it says
command not found, the installer likely didn't add Go's bin directory to
your PATH — the installer's instructions cover the fix for your OS.
You don't need to configure GOPATH
If you've read older Go tutorials, you may have seen instructions about
setting up a GOPATH and putting all your code inside it. Ignore that —
it describes a workflow from before 2019. Modern Go uses modules, which
are the default and require no directory-layout ceremony. You can create a
Go project anywhere on disk, in any folder you like. The next lesson covers
exactly how.
Picking an editor
Any editor with Go support works, but the common choice is
VS Code with the official Go extension.
Installing it also installs gopls, Go's language server, which gives you:
- autocomplete as you type
- jump-to-definition and find-references
- inline errors and warnings before you even compile
- automatic formatting on save
Other editors — Neovim, GoLand, Emacs, Sublime — all speak to gopls
through the Language Server Protocol, so the experience is similar wherever
you land. If you already have a favorite editor, look for its Go or LSP
plugin rather than switching.
From browser to machine
On this site, you write Go in an in-browser editor and click Run, and a
sandboxed environment compiles and executes it for you. That convenience is
exactly what the rest of this chapter shows you how to reproduce locally:
go run compiles and runs a file in one step, no separate build command
needed. Once Go is installed and your editor is wired up, the workflow here
and the workflow on your own machine are the same — you're just no longer
limited to what fits in a browser tab.