There are several ways to install Go depending on your operating system and preferences. We'll cover the most common methods.
Method 1: Official Installer (Recommended)
.pkg file) for the latest version.pkg file/usr/local/go and add it to your PATHMethod 2: Using Homebrew
If you have Homebrew installed, you can install Go with a single command:
brew install go
Method 3: Using MacPorts
If you use MacPorts:
sudo port install go
Verification after installation
After installation, open a new terminal window and verify:
go version
You should see output like: go version go1.23.x darwin/amd64 (or darwin/arm64 for Apple Silicon).
Method 1: Package Manager (Recommended for most distributions)
Ubuntu/Debian
sudo apt update
sudo apt install golang-go
Fedora
sudo dnf install golang
CentOS/RHEL
sudo yum install golang
Arch Linux
sudo pacman -S go
Method 2: Official Binary Distribution
For the latest version or if your distribution's package manager has an outdated version:
.tar.gz file)sudo rm -rf /usr/local/gosudo tar -C /usr/local -xzf go1.23.x.linux-amd64.tar.gz~/.bashrc or ~/.profile:
export PATH=$PATH:/usr/local/go/binsource ~/.bashrcMethod 3: Snap Package
sudo snap install go --classic
Method 1: Official Installer (Recommended)
.msi file).msi fileMethod 2: Manual Installation
C:\Program Files\GoC:\Program Files\Go\bin to your system PATH:
Path variable in System VariablesC:\Program Files\Go\binVerification
Open Command Prompt or PowerShell and run:
go version
You should see: go version go1.23.x windows/amd64
Building Go from source is useful if you want the latest development version or need to customize the build:
Prerequisites
Steps
# Clone the Go repository
git clone https://go.googlesource.com/go
cd go
# Checkout the desired version (e.g., go1.23)
git checkout go1.23
# Build Go (this will take several minutes)
cd src
./make.bash # On Unix-like systems
# or
./make.bat # On Windows
The built Go will be in the bin directory. You'll need to add it to your PATH.
Version managers allow you to easily switch between different Go versions, which is useful for testing or working on projects that require specific versions.
g (Simple Go Version Manager)
Installation:
# Install g
curl -sSL https://git.io/g-install | sh -s
# Or using Homebrew on macOS
brew install g
Usage:
# Install a specific version
g install 1.23.0
# List installed versions
g list
# Switch to a version
g 1.23.0
# Show current version
g version
gvm (Go Version Manager)
Installation:
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
Usage:
# Install a version
gvm install go1.23
# Use a version
gvm use go1.23 --default
# List versions
gvm list