Agentic AI Engineering with Python: Live Course
GoGo Foundations

Installing Go and the Toolchain

Installing Go is genuinely one of the easiest setups in programming. There is one official installer per platform, it bundles everything you need, and when it finishes you have a compiler, a formatter, a test runner, a dependency manager, and a documentation server. No package manager to configure first, no build tool to install separately.

Budget about ten minutes, including the editor setup at the bottom.

Get the installer

Everything comes from one place: go.dev/dl. Download the package for your operating system and architecture. If you are unsure which architecture you have, the notes below cover it.

Windows

Download the .msi installer and run it. The default install location is C:\Program Files\Go, and the installer adds Go to your PATH automatically.

Close and reopen any terminal you already had open. PATH changes do not reach terminals that were already running, and this trips up a lot of people on their first install.

macOS

Download the .pkg installer and run it. Go installs to /usr/local/go and the installer handles the PATH entry.

If you prefer Homebrew:

brew install go

On Apple Silicon machines take the ARM64 build. The Intel build will run under Rosetta, but you will be leaving performance on the table for no reason.

Linux

Download the tarball and extract it into /usr/local, removing any previous installation first:

rm -rf /usr/local/go
tar -C /usr/local -xzf go1.24.0.linux-amd64.tar.gz

Then add Go to your PATH by appending this line to ~/.bashrc or ~/.zshrc:

export PATH=$PATH:/usr/local/go/bin

Reload the shell with source ~/.bashrc or open a new terminal.

Resist the temptation to use apt install golang or your distribution's package manager. Distribution packages are often several releases behind, and an old Go can silently miss language features you will meet in this course. The official tarball takes the same two minutes and gives you the current release.

Verify the installation

Two commands confirm everything worked.

go version

You should see something like:

go version go1.24.0 windows/amd64

Then check the environment the toolchain has configured for itself:

go env GOROOT GOPATH GOBIN

That prints three paths. They are worth understanding once, because they explain where things end up.

VariableWhat it points atDo you set it?
GOROOTWhere Go itself is installedNo, the installer handles it
GOPATHYour workspace for downloaded modules and installed tools, defaults to ~/goRarely, the default is fine
GOBINWhere go install puts binaries, defaults to $GOPATH/binOnly if you want them elsewhere

If you learned Go before 2018, you may remember that all your code had to live inside GOPATH/src. That requirement is gone. With modules, a Go project can live in any folder on your disk. GOPATH now only holds the module cache and installed tool binaries.

Add the tools directory to your PATH

go install places command line tools in $GOPATH/bin, and that folder is not on your PATH by default on every system. Adding it now saves confusion later when you install a linter and the shell claims it does not exist.

On macOS or Linux:

export PATH=$PATH:$(go env GOPATH)/bin

On Windows, add %USERPROFILE%\go\bin to your user PATH through the system environment variables dialog.

Set up your editor

You can write Go in any text editor, but the language server makes a real difference. It is called gopls and it powers autocompletion, jump to definition, inline errors, and automatic formatting on save.

Install the editor extension

For VS Code, install the extension named simply "Go", published by the Go team at Google. For GoLand, everything is built in already. For Neovim, configure gopls through your LSP setup.

Let it install the tools

The first time you open a .go file, VS Code will offer to install gopls and a few helpers. Accept. It downloads them into $GOPATH/bin and takes under a minute.

Turn on format on save

This is the setting that matters most. Go code is formatted by gofmt, there are no options to argue about, and having it applied automatically means you never think about layout again.

settings.json
{
  "editor.formatOnSave": true,
  "[go]": {
    "editor.defaultFormatter": "golang.go"
  }
}

Check that it works

Open a .go file, write badly indented code on purpose, and save. If it snaps into shape, your setup is complete.

The toolchain you just installed

Everything below ships with Go. There is nothing else to install for the majority of this course.

CommandWhat it does
go runCompile and execute in one step, without leaving a binary behind
go buildCompile into an executable file
go installBuild and place the binary in $GOPATH/bin
go testRun tests and benchmarks
go fmtReformat source to the standard style
go vetReport suspicious constructs the compiler allows
go modManage the module and its dependencies
go getAdd or update a dependency
go docPrint documentation for a package or symbol
go cleanRemove build artefacts and cached objects

Try one now to see what a full toolchain feels like:

go doc fmt.Println

That prints the documentation for a standard library function directly in your terminal, offline, with no network call.

When something goes wrong

SymptomCauseFix
go: command not foundPATH does not include Go's bin folderReopen the terminal, then verify the PATH entry
go version shows an old releaseAn older Go is earlier in PATHRemove the old install, or reorder PATH
Installed tool not found$GOPATH/bin is not on PATHAdd it as shown above
gopls keeps crashing in the editorVersion mismatch after a Go upgradeRun go install golang.org/x/tools/gopls@latest
Permission denied on Linux installExtracting into /usr/local needs rootPrefix the tar command with sudo

That is the entire setup, and unlike most language environments, you will not need to revisit it.

Now for the part you actually came for, which is getting a program to run.

How is this guide?

Last updated on