How to Install Go on Windows, Mac, and Linux – Step-by-Step Setup
Installing Go on Windows
- Download the Windows installer (.msi) from the official Go website.
- Run the installer and follow the setup wizard — it automatically sets the
PATHenvironment variable. - Open Command Prompt and run
go versionto confirm installation.
Installing Go on macOS
# Using Homebrew
brew install go
# Verify installation
go version
Installing Go on Linux
wget https://go.dev/dl/go1.22.0.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.22.0.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version
Setting Up Your Workspace
Modern Go uses Go Modules for dependency management, so you no longer need a strict GOPATH directory structure — simply run go mod init myproject inside any folder to start a new project.
Checking That the Installation Really Works
Seeing a version number is a good start, but a quick program confirms that the compiler, module system and PATH all work together. Create a folder anywhere and run these commands:
mkdir hello && cd hello
go mod init example.com/hello
# create main.go with the code below, then:
go run .
go build -o hello .
package main
import "fmt"
func main() {
fmt.Println("Go is installed and working")
}
go run . compiles and runs in one step. go build produces a standalone executable you can copy to another machine with the same operating system. To see where Go keeps its files, run go env GOROOT GOPATH GOBIN.
Making PATH Changes Permanent
On Linux, the export line only lasts for the current terminal. Add it to your shell profile so it survives a restart. Also add the folder where go install places tools, which is $HOME/go/bin by default.
echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> ~/.profile
source ~/.profile
If you use zsh, which is the default on modern macOS, the file is usually ~/.zshrc. On Windows, the installer updates PATH for you, but open a new terminal window afterwards; existing windows still have the old PATH. You can check what Windows sees with where go in Command Prompt.
Upgrading and Troubleshooting
On Linux, the official instructions say to remove the previous installation before extracting a new archive. Extracting on top of an old folder can mix files from two versions and cause confusing build errors.
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go<version>.linux-amd64.tar.gz
On macOS with Homebrew, brew upgrade go handles this. On Windows, running the newer installer replaces the old version.
| Symptom | Likely cause and fix |
|---|---|
go: command not found | PATH not updated; reload the profile or open a new terminal |
| Old version still shown | Two installations exist; check with which go or where go and remove one |
| Installed tools not found | $HOME/go/bin (or the GOBIN folder) missing from PATH |
| Module downloads fail at work | A corporate proxy blocks the default module proxy; ask IT for the approved GOPROXY setting |
| Wrong download for your Mac | Apple silicon needs the arm64 build, Intel Macs need amd64 |
Editor Setup and a Final Checklist
Visual Studio Code with the official Go extension, or GoLand, gives autocompletion, formatting and debugging. The extension offers to install helper tools such as gopls, the Go language server; accept that prompt. Format code with gofmt or let the editor do it on save, because consistent formatting is a strong Go convention.
- Download only from the official Go site or a trusted package manager.
- Confirm
go versionin a fresh terminal. - Run a hello-world module with
go run .. - Add the Go bin folders to PATH permanently.
- Install the editor extension and its tools.
Ready to master real-world Go skills?
Learn Go hands-on with mentor-led, live sessions.