Go (often referred to as Golang) is an open-source programming language created at Google by Robert Griesemer, Rob Pike, and Ken Thompson. Designed for simplicity, concurrency, and high execution speed, Go powers modern cloud-native infrastructure including Docker, Kubernetes, Terraform, Hugo, Caddy, and Prometheus.
While Ubuntu’s default package repositories provide Go binaries via apt, installing official release archives from go.dev/dl ensures access to the latest release builds (Go 1.22+), performance optimizations, and security patches.
Whether configuring a new development environment on Ubuntu 24.04 LTS (Noble Numbat) or 22.04 LTS (Jammy Jellyfish), here is the step-by-step installation guide for 2026.
Last updated: July 24, 2026
Key Takeaways
- Installing via official Go tarballs (.tar.gz) from go.dev guarantees you get the newest stable compiler instead of outdated distribution packages.
- Go binaries must be installed to `/usr/local/go` after removing any previous Go installation directories.
- Configuring PATH environment variables (`/usr/local/go/bin` and `$GOPATH/bin`) in `~/.bashrc` or `~/.zshrc` is required for shell access.
- Go modules (`go.mod`) are the standard dependency management system used for all modern Go projects.
What are the system requirements for installing Go on Linux?
Before installing Go on Ubuntu, Debian, or Linux Mint, ensure your environment meets these baseline dependencies:
- Operating System: Ubuntu 24.04 LTS, 22.04 LTS, Debian 12, or Linux Mint 22
- Utilities:
curlorwget,tar,sudoadministrative access, and a terminal - Architecture: 64-bit x86_64 (
amd64) or ARM64 (arm64) CPU architecture
How do you install Go from official release binaries?
Downloading and extracting the official Go release tarball provides a clean, portable installation isolated under /usr/local/go.
Step 1: Download the Latest Go Release Tarball
Open your terminal (Ctrl+Alt+T) and fetch the latest stable Go release using curl or wget:
# Fetch latest version tag automatically from Go official API
GO_VERSION=$(curl -s https://go.dev/dl/?mode=json | grep -o 'go[0-9.]*' | head -n 1)
# Download 64-bit Linux AMD64 release archive
wget https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gzStep 2: Remove Old Installations and Extract Archive
Remove any pre-existing /usr/local/go directory and extract the fresh archive into /usr/local:
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf ${GO_VERSION}.linux-amd64.tar.gzStep 3: Configure Shell Environment Variables (PATH & GOPATH)
Add Go binaries (/usr/local/go/bin) and your workspace binary path ($HOME/go/bin) to your shell environment file (~/.bashrc for Bash or ~/.zshrc for Zsh):
# Append Go PATH exports to ~/.bashrc
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
echo 'export GOPATH=$HOME/go' >> ~/.bashrc
echo 'export PATH=$PATH:$GOPATH/bin' >> ~/.bashrcStep 4: Reload Shell Profile and Verify
Apply the updated environment variables to your current session:
source ~/.bashrcConfirm that Go is correctly installed and accessible:
go versionExpected output example: go version go1.2x.x linux/amd64
Check full Go environment configuration:
go envHow do you install Go using APT package manager?
If you prefer standard package management via apt, Go is available in Ubuntu default repositories:
sudo apt update
sudo apt install -y golang-goNote: The APT repository version may lag several release versions behind upstream go.dev builds.
How do you create and run your first Go program?
Modern Go uses Go Modules (go.mod) for dependency management.
Step 1: Initialize a Project Directory
Create a project folder and initialize a module:
mkdir hello-go
cd hello-go
go mod init example.com/hello-goThis creates a go.mod file tracking your module path and Go version.
Step 2: Write Main Source File
Create main.go:
nano main.goPaste the following code:
package main
import "fmt"
func main() {
fmt.Println("Hello from Go on Ubuntu!")
}Save and close the file (Ctrl+O, Enter, Ctrl+X).
Step 3: Run and Build the Program
Run your Go program directly without creating a permanent binary:
go run main.goCompile a standalone, optimized binary executable:
go buildRun your compiled binary:
./hello-goTo update Go in the future, re-run the download script. Removing /usr/local/go before unpacking the new tarball ensures stale binary files are completely cleared.
Frequently Asked Questions (PAA)
What is the difference between GOPATH and GOROOT?
GOROOT specifies the directory path where the Go SDK and compiler tools are installed (typically /usr/local/go). GOPATH specifies your user workspace directory (typically $HOME/go) where downloaded third-party packages and compiled binaries are stored.
Where does go install place compiled executable tools?
Binaries installed via go install package@latest are saved to $GOPATH/bin (or $HOME/go/bin). Ensure $GOPATH/bin is in your shell PATH to run installed CLI tools globally.
How do I completely uninstall Go installed via tarball?
Delete the /usr/local/go directory and remove the PATH export lines from your ~/.bashrc or ~/.zshrc file:
sudo rm -rf /usr/local/goRead Next
- How to Install Hugo Static Site Generator on Ubuntu & Linux
- How to Install Docker on Ubuntu, macOS, and Windows
- How to Install Rust and Cargo on Ubuntu, macOS, and Windows
Related Articles
Deepen your understanding with these curated continuations.

How to Install PostgreSQL & pgAdmin 4 on Ubuntu & Linux (2026)
Step-by-step guide to installing PostgreSQL 16/17 and pgAdmin 4 on Ubuntu 24.04/22.04 LTS via official PPA with remote access and security configuration.

How to Install Redis Server & Redis CLI on Ubuntu & Linux (2026)
Step-by-step guide to installing Redis Server and Redis CLI on Ubuntu 24.04/22.04 LTS via official APT repository with security, password, and systemd setup.

How to Install Rust and Cargo on Ubuntu, macOS, and Windows (2026)
Learn how to install Rust, Cargo, and Rustup on Ubuntu 24.04/22.04 LTS, macOS, and Windows with toolchain management and build configuration.



