Installing Go
Context
Section titled “Context”To start programming in Go, you need to install the Go toolchain (compiler, standard library, and command‑line tools). Go supports Linux, macOS, Windows, and several other platforms.
Installation steps per operating system
Section titled “Installation steps per operating system”- Download the latest tarball from go.dev/dl, e.g.,
go1.24.0.linux-amd64.tar.gz. - Remove any previous Go installation (usually
/usr/local/go):Terminal window sudo rm -rf /usr/local/go - Extract the tarball into
/usr/local:Terminal window sudo tar -C /usr/local -xzf go1.24.0.linux-amd64.tar.gz - Add
/usr/local/go/binto yourPATHenvironment variable (add to~/.profileor~/.bashrc):Terminal window export PATH=$PATH:/usr/local/go/bin
- Using the official installer: download the
.pkgfile from go.dev/dl and run it. - Using Homebrew:
brew install go.
Windows
Section titled “Windows”- Download the MSI installer from go.dev/dl and run it. It will automatically set up the
PATHenvironment variable.
Verify the installation
Section titled “Verify the installation”After installation, open a new terminal and run:
Code example
Section titled “Code example”go versionOutput
Section titled “Output”go version go1.24.0 linux/amd64Additional verification
Section titled “Additional verification”Check the Go environment:
go envThis shows variables like GOROOT (installation path), GOPATH (legacy workspace, not needed with modules), and GOOS/GOARCH.