go: command not found

The go command could not be run. Either Go is not installed, or it is installed and its bin directory is not on PATH.

The fix

Install Go, then open a new terminal. A shell that was already running kept the old PATH and will not see it.

Terminal
# macOS
$brew install go
# Windows: use the .msi from go.dev/dl, which sets PATH for you.
# Debian and Ubuntu: the apt package is usually years behind, so take
# the tarball from go.dev/dl instead.
$sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go*.tar.gz
$echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile

Why it happens

Reinstalling usually does not help, because the problem is normally PATH rather than the installation. A shell reads PATH once, when it starts, so a terminal that was already open keeps the old value no matter how many times you install.

On Windows this includes the terminal inside your editor: restart the editor, not just the panel.

A related case: go version works but a tool you installed with go install does not. That is a different directory. Add $(go env GOPATH)/bin, which is %USERPROFILE%\go\bin on Windows.

How to tell it worked

Terminal
$go version

Still stuck? The troubleshooting page covers more, and the errors guide lists every message with its cause. Running grit doctor --env checks this machine for all of them at once.