How to Install Golang on Ubuntu 26.04, 24.04 and 22.04

Last updated Tuesday, April 28, 2026 7:42 pm Joshua James 12 min read

Go projects can be sensitive to the compiler version, especially when a module targets a newer language release or a build expects a matching toolchain patch. To install Go on Ubuntu cleanly, start by choosing whether you want Ubuntu’s packaged toolchain, a community APT backport, an official upstream tarball, or a source build for compiler work.

Ubuntu 26.04 already ships the Go 1.26 series through APT, while Ubuntu 24.04 and 22.04 keep older repository versions for release stability. If your project needs the current upstream release, a pinned Go 1.24 or 1.25 tarball, or the newest security patch before it reaches a repository, the official go.dev tarball path gives you the most direct control.

Compare Go Installation Methods on Ubuntu

Choose one primary method for each system. Mixing an APT-managed Go package with a separate /usr/local/go tarball can work, but only when you deliberately control PATH order and know which go binary your shell will run.

MethodChannelVersion PatternUpdatesBest For
APTUbuntu repositoryGo 1.26 on 26.04, Go 1.22 on 24.04, Go 1.18 on 22.04Normal APT updatesDefault choice on Ubuntu 26.04 and stable distro-managed builds
PPAgolang-backportsCurrent Go series for 24.04 and 22.04APT package updates after adding the PPAOlder LTS systems that need a newer APT-managed Go
Tarballgo.dev downloadsCurrent stable or a pinned archived releaseManual replacementExact upstream versions, pinned project toolchains, and fastest security patch access
SourceGo source repositoryRelease tag, branch, or commitManual rebuildGo contributors and compiler experiments

Recommendation: Use Ubuntu APT on Ubuntu 26.04 unless you need an exact upstream patch release. On Ubuntu 24.04 or 22.04, use the official tarball for pinned or current upstream releases, or use the golang-backports PPA when you specifically want a current Go series managed by APT from a community Launchpad source. Reserve the source build for contributors or developers testing compiler changes.

This article covers Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS. The official tarball and source build install to /usr/local/go and work independently of Ubuntu’s package version. The golang-backports PPA currently publishes golang-go for Ubuntu 24.04 and 22.04, while Ubuntu 26.04 already has a Go 1.26 package in the default repository.

Update Ubuntu System Packages

Before installing Go, update your package lists and upgrade existing packages to ensure your system has the latest security patches and avoid potential conflicts during installation.

sudo apt update && sudo apt upgrade

The commands in this article use sudo. If your account is not already allowed to run administrative commands, follow the Ubuntu sudoers setup guide first, then return to this installation.

Install the required utilities for downloading and extracting archives. These packages are typically pre-installed on desktop systems, but minimal or server installations may lack them.

sudo apt install curl tar

Install Go from APT Repository

Use the Ubuntu repository when the packaged Go series is new enough for your projects. This is the cleanest option on Ubuntu 26.04 because the default repository already tracks the Go 1.26 series. Ubuntu 24.04 and 22.04 remain on older series, which is fine for stable build hosts but may be too old for projects that require newer language or toolchain features.

sudo apt install golang-go

Verify the installation by checking the version:

go version

The release series varies by Ubuntu version. Package metadata currently maps to these Go series:

go version go1.26.x linux/amd64    # Ubuntu 26.04 (Resolute)
go version go1.22.x linux/amd64    # Ubuntu 24.04 (Noble)
go version go1.18.x linux/amd64    # Ubuntu 22.04 (Jammy)

If the repository version meets your project requirements, continue to the Hello World verification section. APT and PPA installs place go in the normal system path, so they do not need the /usr/local/go PATH setup used by tarball and source builds.

Install Go from Golang-Backports PPA

The golang-backports PPA is a community-maintained Launchpad archive that currently publishes Go 1.26 packages for Ubuntu 24.04 (Noble) and 22.04 (Jammy). Use it when you want a newer APT-managed Go on those older LTS releases. Skip this method on Ubuntu 26.04 unless the PPA later publishes a package that improves on Ubuntu’s own golang-go candidate.

Add the PPA Repository

Install the software properties package so Ubuntu can add and remove the Launchpad PPA cleanly:

sudo apt install software-properties-common -y

Add the PPA to make the backported Go packages available on Ubuntu 24.04 or 22.04:

sudo add-apt-repository ppa:longsleep/golang-backports -y

Update your package list to include the newly available Go releases:

sudo apt update

Install Go from the PPA

Install Go using the golang-go metapackage. On the supported older LTS releases, the PPA candidate currently resolves to the Go 1.26 series:

sudo apt install golang-go

Verify the installation:

go version
go version go1.26.x linux/amd64

The PPA also publishes versioned packages such as golang-1.26 and golang-1.26-go. Install a versioned package only when you intentionally need parallel Go trees under /usr/lib/; otherwise, use golang-go so APT follows the archive’s default Go series.

Switch Between Go Versions

If you intentionally install multiple versioned Go packages from the PPA, use update-alternatives to choose which binary answers as /usr/bin/go. Register only paths that exist on your system:

sudo update-alternatives --install /usr/bin/go go /usr/lib/go-1.25/bin/go 125
sudo update-alternatives --install /usr/bin/go go /usr/lib/go-1.26/bin/go 126

The numbers are priority values; higher numbers are preferred in auto mode. List the available alternatives:

sudo update-alternatives --list go
/usr/lib/go-1.25/bin/go
/usr/lib/go-1.26/bin/go

Switch between versions interactively:

sudo update-alternatives --config go
There are 2 choices for the alternative go (providing /usr/bin/go).

  Selection    Path                      Priority   Status
------------------------------------------------------------
* 0            /usr/lib/go-1.26/bin/go   126       auto mode
  1            /usr/lib/go-1.25/bin/go   125       manual mode
  2            /usr/lib/go-1.26/bin/go   126       manual mode

Press <enter> to keep the current choice[*], or type selection number:

Enter the selection number corresponding to your desired version. Verify the change:

go version

Install Go from Official Tarball

Installing from the official go.dev downloads page gives you the upstream Go release directly from the Go project. Use this method when you need the current stable release on Ubuntu 24.04 or 22.04, an exact archived version such as Go 1.24.x, or a toolchain that stays independent from Ubuntu’s package manager.

Check System Architecture

Confirm your system architecture to ensure you download the correct package:

dpkg --print-architecture
amd64

The commands below support amd64 and arm64, which match the official Linux tarballs published by the Go project for most Ubuntu workstations, servers, and ARM development boards. If your system reports another architecture, use the download table on go.dev instead of forcing one of these filenames.

Download the Latest Go Release

The following commands detect your architecture, read the current stable version from go.dev, and download the matching Linux tarball. Run the later extraction command in the same terminal so GO_TARBALL remains set.

cd /tmp
GO_ARCH=$(dpkg --print-architecture)
case "$GO_ARCH" in
  amd64|arm64) ;;
  *) echo "Unsupported architecture for this shortcut: $GO_ARCH"; exit 1 ;;
esac
GO_VERSION=$(curl -fsSL 'https://go.dev/VERSION?m=text' | head -n 1)
[ -z "$GO_VERSION" ] && echo "Failed to detect Go version" && exit 1
GO_TARBALL="${GO_VERSION}.linux-${GO_ARCH}.tar.gz"
echo "Downloading ${GO_TARBALL}..."
curl -fLO "https://go.dev/dl/${GO_TARBALL}"
  • dpkg --print-architecture: Reports Ubuntu’s package architecture, such as amd64 or arm64
  • https://go.dev/VERSION?m=text: Returns the current stable Go version as plain text
  • GO_TARBALL: Builds a filename such as go1.26.2.linux-amd64.tar.gz
  • curl -fLO: Downloads the archive and fails if the URL does not exist

Manual Go tarball URLs follow the format https://go.dev/dl/goVERSION.linux-ARCH.tar.gz, such as https://go.dev/dl/go1.26.2.linux-amd64.tar.gz. For pinned Go 1.24 builds or older archived filenames such as go1.22.4.linux-amd64.tar.gz, choose the exact file from go.dev/dl rather than guessing a patch number.

Remove Previous Go Installation

Remove any existing Go installation in /usr/local/go to prevent file conflicts and ensure a clean environment:

The following command deletes the existing Go installation directory. Ensure you do not have any custom data stored inside /usr/local/go before proceeding.

sudo rm -rf /usr/local/go

Extract Go Archive

Extract the downloaded archive to /usr/local. This step creates the /usr/local/go directory containing the Go toolchain:

sudo tar -C /usr/local -xzf "/tmp/${GO_TARBALL}"
rm -f "/tmp/${GO_TARBALL}"

Verify the extraction succeeded:

/usr/local/go/bin/go version
go version go1.26.2 linux/amd64

Install Go from Source (Advanced)

Building Go from source is for Go contributors, compiler testing, and unusual toolchain experiments. The Go toolchain is written in Go, so source builds need a bootstrap compiler that satisfies the version rule in the official source documentation. For the current Go 1.26 release line, use a Go 1.24 or newer bootstrap compiler.

Install Build Prerequisites

Install Git on Ubuntu for cloning the source repository. Install GCC on Ubuntu to enable cgo support, which allows Go programs to call C libraries (similar to how Python ctypes or Java JNI bridge to native code):

sudo apt update
sudo apt install git gcc

If you only need pure Go programs without C library integration, you can skip GCC and set CGO_ENABLED=0 during the build. However, GCC is recommended for full functionality.

Download Bootstrap Compiler

Download a Go 1.24 bootstrap compiler from go.dev. The example below uses Go 1.24.13, which satisfies the bootstrap requirement for Go 1.26 source builds. If you build a future Go release, recheck the bootstrap requirement in the official source installation documentation.

cd /tmp
GO_ARCH=$(dpkg --print-architecture)
GO_BOOTSTRAP=go1.24.13
case "$GO_ARCH" in
  amd64|arm64) ;;
  *) echo "Unsupported architecture for this shortcut: $GO_ARCH"; exit 1 ;;
esac
if [ -e /usr/local/go ]; then
  echo "/usr/local/go already exists. Move or remove it before creating /usr/local/go-bootstrap."
  exit 1
fi
curl -fLO "https://go.dev/dl/${GO_BOOTSTRAP}.linux-${GO_ARCH}.tar.gz"
sudo rm -rf /usr/local/go-bootstrap
sudo tar -C /usr/local -xzf "${GO_BOOTSTRAP}.linux-${GO_ARCH}.tar.gz"
sudo mv /usr/local/go /usr/local/go-bootstrap
rm -f "${GO_BOOTSTRAP}.linux-${GO_ARCH}.tar.gz"

Verify the bootstrap compiler is available:

/usr/local/go-bootstrap/bin/go version
go version go1.24.13 linux/amd64

Clone Go Source Repository

Clone the Go source from the official repository and check out the current stable release tag. The command reads the same version endpoint used by the tarball method, then fetches only that tag to minimize download size:

cd /tmp
GO_TAG=$(curl -fsSL 'https://go.dev/VERSION?m=text' | head -n 1)
[ -z "$GO_TAG" ] && echo "Failed to detect Go version" && exit 1
echo "Cloning $GO_TAG..."
rm -rf /tmp/goroot
git clone --depth 1 --branch "$GO_TAG" https://go.googlesource.com/go goroot

To build a specific version, replace the GO_TAG detection with your desired tag, such as GO_TAG=go1.25.9. Confirm the tag and bootstrap requirement on go.dev/dl and the Go source documentation before building older or newer release lines.

Build Go from Source

Set the GOROOT_BOOTSTRAP environment variable to point to your bootstrap compiler, then run the build script:

export GOROOT_BOOTSTRAP=/usr/local/go-bootstrap
cd /tmp/goroot/src
./make.bash

The build takes approximately 2-5 minutes depending on your hardware. When complete, you see output similar to:

Building Go cmd/dist using /usr/local/go-bootstrap. (go1.24.13 linux/amd64)
Building Go toolchain1 using /usr/local/go-bootstrap.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain2.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for linux/amd64.
---
Installed Go for linux/amd64 in /tmp/goroot
Installed commands in /tmp/goroot/bin

Install Built Go to System Location

Move the compiled Go tree to the standard installation location and clean up the bootstrap compiler:

sudo rm -rf /usr/local/go
sudo mv /tmp/goroot /usr/local/go
sudo rm -rf /usr/local/go-bootstrap

Verify the source-built installation:

/usr/local/go/bin/go version
go version go1.26.2 linux/amd64

The source-built Go installs to the same location as the tarball method (/usr/local/go), so the environment variable configuration in the next section applies to both methods.

Configure PATH for Tarball or Source Installs

Skip this section if you installed Go with APT or the PPA; those methods place go under /usr/bin. Tarball and source installs place the toolchain under /usr/local/go, so your shell needs that binary directory in PATH. Modern Go automatically defaults GOPATH to $HOME/go, but adding $HOME/go/bin to PATH lets commands installed with go install run without typing their full path.

Temporary PATH for the Current Session

To test Go immediately without modifying configuration files, export the PATH change in your current terminal. This setting lasts only until you close that terminal:

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

Permanent PATH for Bash

For permanent configuration with bash, add the PATH line to ~/.profile. Ubuntu reads this file for login shells, including many desktop terminal sessions launched after a fresh sign-in:

grep -q '/usr/local/go/bin' ~/.profile || cat >> ~/.profile << 'EOF'

# Go programming language
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
EOF

The grep -q check prevents duplicate entries if you run the command again. Load the updated configuration into your current terminal session:

source ~/.profile

Add the same PATH line to ~/.bashrc only if your terminal setup does not read ~/.profile. Keeping the line in one file avoids duplicate PATH entries.

Permanent PATH for Zsh

If you use zsh instead of bash, add the configuration to ~/.zshrc:

grep -q '/usr/local/go/bin' ~/.zshrc 2>/dev/null || cat >> ~/.zshrc << 'EOF'

# Go programming language
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
EOF
source ~/.zshrc

System-Wide PATH for All Users

To make a tarball or source-built Go toolchain available for all users, create a profile script under /etc/profile.d/. This writes a single PATH line and leaves each user’s default GOPATH at $HOME/go:

printf '%s\n' 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' | sudo tee /etc/profile.d/golang.sh > /dev/null

This script runs automatically for all users during login. Log out and back in, or source it manually to apply immediately:

source /etc/profile.d/golang.sh

Verify PATH and Go Environment

After applying the PATH change, verify that the shell can find Go and that the expected version responds:

go version
go version go1.26.2 linux/amd64

Version numbers shown here reflect the latest stable upstream release verified for this refresh. Your output may show a newer patch version after Go publishes another release.

Confirm Go’s environment paths. The tarball and source methods should report /usr/local/go as GOROOT, while APT and PPA installs normally report a path under /usr/lib/go-*:

go env | grep -E '^(GOPATH|GOROOT|GOTOOLCHAIN)='
GOPATH='/home/username/go'
GOROOT='/usr/local/go'
GOTOOLCHAIN='auto'
  • GOROOT: Location of the Go installation itself. Do not set this manually unless a Go developer workflow specifically requires it.
  • GOPATH: Your personal Go workspace, defaulting to ~/go, where Go stores downloaded modules, build cache references, and binaries installed with go install.

Verify Installation with Hello World

Create a simple Go program to confirm the installation works correctly. This test verifies that the compiler runs, modules initialize properly, and the build process completes successfully.

Create a project directory and initialize a Go module:

mkdir -p ~/go-hello && cd ~/go-hello
go mod init hello
go: creating new go.mod: module hello

Create the main program file:

cat > hello.go << 'EOF'
package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}
EOF

Build and run the program:

go build -o hello
./hello
Hello, World!

If you see the output above, Go is correctly installed and configured. You can now develop Go applications on your Ubuntu system.

Clean up the test project when finished:

cd ~ && rm -rf ~/go-hello

Update Go to a New Version

Go releases occur regularly with security patches and new features. The update process depends on your installation method.

Update APT or PPA Installation

If you installed Go via APT or the PPA, update through your package manager:

sudo apt update
sudo apt install --only-upgrade golang-go

Update Tarball Installation

Check your current version:

go version

Download and install the latest release:

cd /tmp
GO_ARCH=$(dpkg --print-architecture)
case "$GO_ARCH" in
  amd64|arm64) ;;
  *) echo "Unsupported architecture for this shortcut: $GO_ARCH"; exit 1 ;;
esac
GO_VERSION=$(curl -fsSL 'https://go.dev/VERSION?m=text' | head -n 1)
GO_TARBALL="${GO_VERSION}.linux-${GO_ARCH}.tar.gz"
[ -z "$GO_VERSION" ] && echo "Failed to detect Go version" && exit 1
curl -fLO "https://go.dev/dl/${GO_TARBALL}"
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf "${GO_TARBALL}"
rm -f "/tmp/${GO_TARBALL}"

Verify the update completed successfully:

go version
go version go1.26.2 linux/amd64

Your existing Go projects and installed packages in $GOPATH remain intact after updating. The Go toolchain maintains backward compatibility, so projects built with older versions typically compile without modification.

Update Script for Source-Compiled Go

If you installed Go from source and prefer an automated update process, create the following script. It detects the latest stable version, builds that tag, and uses your existing source-built Go installation as the bootstrap compiler:

cat > ~/update-go-source.sh << 'SCRIPT'
#!/bin/bash
set -e

# Refuse to run as root
if [ "$(id -u)" -eq 0 ]; then
  echo "Run this script as a regular user (it uses sudo only for install steps)."
  exit 1
fi

# Check required build tools and source-built Go
for cmd in git curl; do
    if ! command -v "$cmd" > /dev/null 2>&1; then
        echo "Error: $cmd is missing; install it to continue."
        exit 1
    fi
done
if [ ! -x /usr/local/go/bin/go ]; then
    echo "Error: /usr/local/go/bin/go was not found."
    exit 1
fi

echo "Checking sudo access for the install step..."
sudo -v

# Get current and latest versions
CURRENT_VERSION=$(/usr/local/go/bin/go version 2>/dev/null | grep -oP 'go[0-9]+\.[0-9]+\.[0-9]+' || echo "none")
LATEST_TAG=$(curl -fsSL 'https://go.dev/VERSION?m=text' | head -n 1)

if [ -z "$LATEST_TAG" ]; then
    echo "Error: Could not detect latest Go version from go.dev"
    exit 1
fi

echo "Current version: $CURRENT_VERSION"
echo "Latest version:  $LATEST_TAG"

if [ "$CURRENT_VERSION" = "$LATEST_TAG" ]; then
    echo "Current Go version matches latest stable release."
    exit 0
fi

echo "Updating to $LATEST_TAG..."
BUILD_DIR=$(mktemp -d /tmp/go-source-update.XXXXXX)
cleanup() {
    rm -rf "$BUILD_DIR"
}
trap cleanup EXIT
cd "$BUILD_DIR"

# Use current Go as bootstrap
export GOROOT_BOOTSTRAP=/usr/local/go

# Clone and build
echo "Cloning source repository..."
git clone --depth 1 --branch "$LATEST_TAG" https://go.googlesource.com/go go
cd go/src
echo "Building Go (this may take 2-5 minutes)..."
./make.bash

# Install
echo "Installing..."
INSTALL_BACKUP=/usr/local/go.bak
sudo rm -rf "$INSTALL_BACKUP"
sudo mv /usr/local/go "$INSTALL_BACKUP"
if ! sudo mv "$BUILD_DIR/go" /usr/local/go; then
    sudo mv "$INSTALL_BACKUP" /usr/local/go
    echo "Install failed; restored the previous Go installation."
    exit 1
fi
sudo rm -rf "$INSTALL_BACKUP"

echo "Successfully updated to $(/usr/local/go/bin/go version)"
SCRIPT
chmod +x ~/update-go-source.sh

Run the update script manually when you want to upgrade:

~/update-go-source.sh
Checking sudo access for the install step...
Current version: go1.26.1
Latest version:  go1.26.2
Updating to go1.26.2...
Cloning source repository...
Building Go (this may take 2-5 minutes)...
Installing...
Successfully updated to go version go1.26.2 linux/amd64

Avoid automating this script with cron. Source compilation can fail due to network issues, missing dependencies after system updates, or breaking changes between major versions. Run the script manually so you can monitor the output and address any problems before they affect your development environment.

Troubleshoot Common Go Issues

Command Not Found After Installation

If you run go version and see “command not found,” your shell cannot locate the Go binary.

bash: go: command not found

Confirm Go is correctly installed by checking if the binary exists:

ls -la /usr/local/go/bin/go

A successful result shows the binary with its permissions and size:

-rwxr-xr-x 1 root root 16441344 Nov 12 18:02 /usr/local/go/bin/go

If you see “No such file or directory,” Go is not installed. Return to the installation section and repeat the tarball extraction. When the file exists but the command still fails, check whether your shell profile includes the Go path:

grep "go/bin" ~/.profile

No output indicates the export line is missing. Add it:

echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> ~/.profile
source ~/.profile

Verify the fix worked:

go version
go version go1.26.2 linux/amd64

Version Conflict Between APT and Tarball

If you previously installed Go via APT and then installed the official tarball, both versions may conflict if /usr/bin/go appears before /usr/local/go/bin in PATH. Remove the APT package first when the tarball should be your only Go installation:

sudo apt purge golang-go golang-src

Verify only the tarball version remains and appears first in your shell:

which -a go
go version
/usr/local/go/bin/go
go version go1.26.2 linux/amd64

Fix Compile Version Mismatch Errors

If Go prints a compile mismatch error, the active go command is seeing files from two different toolchain versions. This commonly happens when a tarball is extracted over an existing /usr/local/go directory instead of replacing that directory first.

compile: version "go1.26.2" does not match go tool version "go1.26.1"

Check which binary your shell is running and which Go root it reports:

which -a go
go env GOROOT
go version

If the tarball installation under /usr/local/go should be the active toolchain, reinstall it cleanly instead of extracting over the old directory.

The next command deletes /usr/local/go. Confirm that directory only contains the Go toolchain before removing it.

cd /tmp
GO_ARCH=$(dpkg --print-architecture)
case "$GO_ARCH" in
  amd64|arm64) ;;
  *) echo "Unsupported architecture for this shortcut: $GO_ARCH"; exit 1 ;;
esac
GO_VERSION=$(curl -fsSL 'https://go.dev/VERSION?m=text' | head -n 1)
[ -z "$GO_VERSION" ] && echo "Failed to detect Go version" && exit 1
GO_TARBALL="${GO_VERSION}.linux-${GO_ARCH}.tar.gz"
curl -fLO "https://go.dev/dl/${GO_TARBALL}"
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf "${GO_TARBALL}"
rm -f "${GO_TARBALL}"
hash -r
/usr/local/go/bin/go version

GOPATH Permission Issues

If go install fails with permission errors, check the default GOPATH and the directory owner. You usually do not need to set GOPATH manually; Go defaults it to $HOME/go.

go env GOPATH
ls -la $(go env GOPATH)

The GOPATH directory should be owned by your user. If it does not exist, Go creates it automatically on first use. If permissions are incorrect, fix them:

sudo chown -R $USER:$USER ~/go

Module Download Errors

If go get or go mod download fails with network errors, check your proxy settings:

go env | grep PROXY
GOPROXY='https://proxy.golang.org,direct'
GONOPROXY=''
GOPRIVATE=''

The default GOPROXY setting works for most users. If you are behind a corporate proxy or firewall, you may need to configure HTTP_PROXY and HTTPS_PROXY environment variables, or set GOPROXY=direct to bypass the Go module proxy.

Remove Go from Ubuntu

Removal steps depend on your installation method.

Remove APT or PPA Installation

If you installed Go through the default APT package or the PPA golang-go metapackage, remove the package-managed toolchain with APT:

sudo apt purge golang-go golang-src

If you intentionally installed a versioned Go package from the PPA, remove that series as well. Adjust 1.26 if you installed a different versioned package:

sudo apt purge golang-1.26 golang-1.26-go golang-1.26-src

If APT reports autoremovable packages afterward, review them before removing anything else:

sudo apt autoremove --dry-run

Run the cleanup only if the preview shows packages you no longer need:

sudo apt autoremove

If you added the golang-backports PPA and no longer need it, remove the source and refresh APT metadata:

sudo add-apt-repository --remove ppa:longsleep/golang-backports -y
sudo apt update

Check that the package-managed Go packages no longer remain installed:

dpkg -l golang-go golang-src golang-1.26 golang-1.26-go golang-1.26-src 2>/dev/null | grep '^ii' || echo "Package-managed Go packages not installed"

If you configured update-alternatives for Go, remove those entries:

sudo update-alternatives --remove-all go 2>/dev/null || true

Remove Tarball or Source-Compiled Installation

Both the official tarball and source compilation methods install Go to /usr/local/go, so the removal process is identical. Remove the installation directory:

The following command deletes the existing Go installation directory. Ensure you do not have any custom data stored inside /usr/local/go before proceeding.

sudo rm -rf /usr/local/go

If you built from source and the bootstrap compiler still exists, remove it as well:

sudo rm -rf /usr/local/go-bootstrap

Remove the update script if you created one:

rm -f ~/update-go-source.sh

Remove Environment Configuration

Remove the Go-related exports from your shell profile. Edit the appropriate file based on your shell and configuration method:

  • Bash users: Edit ~/.profile or ~/.bashrc
  • Zsh users: Edit ~/.zshrc
  • System-wide configuration: Remove /etc/profile.d/golang.sh

For user-level configuration, open your profile file:

nano ~/.profile

Delete the lines containing /usr/local/go/bin or $HOME/go/bin, then save and exit. If an older setup also added an explicit GOPATH line, remove that line too.

If you configured Go system-wide, remove the profile script:

sudo rm -f /etc/profile.d/golang.sh

Remove Go Workspace (Optional)

The ~/go directory contains downloaded modules, compiled binaries, and build cache from your projects, including any Go tools you installed with go install. The following command permanently deletes this workspace. Back up any important code before running this.

Remove the Go workspace directory and build cache if you no longer need cached modules and installed binaries:

rm -rf ~/go
rm -rf ~/.cache/go-build

Verify Go is completely removed by starting a new terminal session and checking:

command -v go || echo "Go not found"
Go not found

Conclusion

Go is ready on Ubuntu once the selected method matches your project requirements and go version reports the expected toolchain. Ubuntu 26.04 can usually stay with the default APT package, while Ubuntu 24.04 and 22.04 users who need Go 1.26 can choose between the community PPA and the official tarball. For development workflows, pair the toolchain with Git on Ubuntu, GCC on Ubuntu for cgo builds, or Docker on Ubuntu for containerized builds.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: