MeshWorld India LogoMeshWorld.
HowToGoGolangLinuxUbuntuProgramming5 min read

How to Install Go (Golang) on Ubuntu & Linux (2026)

Vishnu
By Vishnu
·
Vishnu
Updated by Vishnu
|Updated: Jul 24, 2026
How to Install Go (Golang) on Ubuntu & Linux (2026)

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: curl or wget, tar, sudo administrative 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:

bash
# 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.gz

Step 2: Remove Old Installations and Extract Archive

Remove any pre-existing /usr/local/go directory and extract the fresh archive into /usr/local:

bash
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf ${GO_VERSION}.linux-amd64.tar.gz

Step 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):

bash
# 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' >> ~/.bashrc

Step 4: Reload Shell Profile and Verify

Apply the updated environment variables to your current session:

bash
source ~/.bashrc

Confirm that Go is correctly installed and accessible:

bash
go version

Expected output example: go version go1.2x.x linux/amd64

Check full Go environment configuration:

bash
go env

How do you install Go using APT package manager?

If you prefer standard package management via apt, Go is available in Ubuntu default repositories:

bash
sudo apt update
sudo apt install -y golang-go

Note: 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:

bash
mkdir hello-go
cd hello-go
go mod init example.com/hello-go

This creates a go.mod file tracking your module path and Go version.

Step 2: Write Main Source File

Create main.go:

bash
nano main.go

Paste the following code:

go
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:

bash
go run main.go

Compile a standalone, optimized binary executable:

bash
go build

Run your compiled binary:

bash
./hello-go

Pro Tip: Updating Go via Release Tarball

To 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:

bash
sudo rm -rf /usr/local/go

Share_This Twitter / X
Vishnu
Written By

Vishnu

Founder & Principal Architect at MeshWorld. Senior engineer and instructor specializing in AI agent systems, scalable web architecture, and modern development workflows.

Vishnu
Updated By

Vishnu

Founder & Principal Architect at MeshWorld. Senior engineer and instructor specializing in AI agent systems, scalable web architecture, and modern development workflows.

Enjoyed this article?

Support MeshWorld and help us create more technical content