Go September 27, 2024 Aditya Rawas

How to Install Go on Linux, macOS, and Windows

If you’re excited to start coding in Go (Golang), you’re in the right place. In this easy-to-follow guide, you’ll learn how to install Go on Linux, macOS, and Windows.

Before jumping into the installation steps, head over to the official Go website and download the installer for your operating system.


Installing Go on Linux

1. Remove any previous Go installations

If you’ve installed Go before, start fresh by removing the old version:

sudo rm -rf /usr/local/go

Now extract the archive you downloaded into /usr/local:

sudo tar -C /usr/local -xzf go1.23.1.linux-amd64.tar.gz

Pro Tip: Always use sudo for these commands to ensure you have the right permissions. Also, never extract into an existing /usr/local/go folder — it can break the installation.

2. Update your PATH

Add Go’s bin directory to your PATH. Open $HOME/.profile (or /etc/profile for system-wide installs) and append:

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

Apply the change immediately:

source $HOME/.profile

3. Verify the installation

go version

You should see something like go version go1.23.1 linux/amd64.


Installing Go on macOS

1. Run the installer

After downloading the .pkg file from the Go website, open it and follow the on-screen prompts. Go will install automatically to /usr/local/go.

2. Check your PATH

The installer typically adds /usr/local/go/bin to your PATH automatically. If not, add it manually to ~/.zshrc or ~/.bash_profile:

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

3. Restart your terminal

Close and reopen your terminal for the changes to take effect, or run:

source ~/.zshrc

4. Verify the installation

go version

If you see the installed version printed, you’re good to go.


Installing Go on Windows

1. Run the MSI installer

Open the downloaded .msi file and follow the installation wizard. By default, Go installs to C:\Program Files\Go.

2. Environment setup

The installer automatically adds Go to your system PATH. After installation, close and reopen any Command Prompt windows for the changes to take effect.

3. Verify the installation

Open Command Prompt (search “cmd” in the Start menu) and run:

go version

You should see something like go version go1.23.1 windows/amd64.


Wrapping Up

Whether you’re on Linux, macOS, or Windows, installing Go is straightforward. Once Go is up and running, you can start building efficient, high-performance applications right away.

If you run into any issues during setup, check the official Go documentation for troubleshooting tips.