Website Vidya
Cloud & DevOpsStep-by-Step Guide

How to Install Go on Ubuntu 24.04

Step-by-step tutorial on how to install Go on Ubuntu 24.04 LTS. Download official Golang tarball, configure GOPATH and PATH, and build a test app.

RR
Rajesh RayLead Systems Educator
Published:
6 min read
PDF Cheat Sheet
How to Install Go on Ubuntu 24.04
AI Executive SummaryWebsiteVidya AI

6 min read

Step-by-step tutorial on how to install Go on Ubuntu 24.04 LTS. Download official Golang tarball, configure GOPATH and PATH, and build a test app.

Key Highlights
  • Prerequisites and Supported Releases
  • Step 1: Updating System Packages and Installing Download Utilities
  • Step 2: Downloading the Official Go Binary Archive
Grounded in full engineering runbookWebsiteVidya AI Engine

Go (often referred to as Golang) is an open-source, statically typed, compiled programming language engineered at Google by Robert Griesemer, Rob Pike, and Ken Thompson. Renowned for its extreme execution speed, ergonomic syntax, built-in memory safety, and native concurrency primitives (goroutines and channels), Go powers the foundation of modern cloud-native computing, container engines like Docker and Podman, orchestration systems like Kubernetes, and microservice architectures.

While Ubuntu 24.04 includes a packaged version of Go in its default universe repositories, the distro packages frequently lag behind the newest upstream language specifications, security fixes, and compiler optimizations. Learning how to install go on ubuntu 24.04 using official binary tarballs ensures you have access to the absolute latest stable Go release, modern toolchain diagnostics, and complete control over your compiler path.

In this comprehensive step-by-step tutorial, we demonstrate how to download and verify the official Go binary release on Ubuntu 24.04 LTS (Noble Numbat), extract it into the system binary hierarchy at /usr/local/go, configure the essential PATH, GOPATH, and GOBIN environment variables, and compile a production-ready concurrent test application.

Advertisement

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Before proceeding, ensure you have the following requirements satisfied:

  • A server or workstation running Ubuntu 24.04 LTS with terminal access.
  • A non-root user account configured with sudo administrative privileges.
  • Basic familiarity with the Linux command line, curl, and tar.
  • An active internet connection to download official Golang archives.

Step 1: Updating System Packages and Installing Download Utilities

Before fetching third-party language binaries, ensure your local APT package database is refreshed and that essential downloading and archiving tools are installed on your system.

Run the following command to update package lists and verify that curl, tar, and sha256sum utilities are available.

Advertisement

These utilities are required to securely fetch and verify the cryptographic checksum of the Golang distribution.

# Update package repository index
sudo apt update && sudo apt upgrade -y

# Install prerequisite archive and networking tools
sudo apt install -y curl wget tar coreutils

Step 2: Downloading the Official Go Binary Archive

Navigate to the official Go downloads webpage or use curl to detect and download the latest stable 64-bit Linux tarball. As of Ubuntu 24.04 LTS, Go 1.23.x (or latest stable) is standard.

Download the official Linux x86_64 tarball directly to your /tmp directory using wget.

For systems running ARM64 architecture (such as AWS Graviton or Raspberry Pi 4/5), ensure you select the go*.linux-arm64.tar.gz archive instead.

Advertisement
# Identify latest stable release version
GO_VERSION="1.23.2"

# Download official Go release tarball to /tmp
wget https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz -O /tmp/go.tar.gz

Step 3: Verifying Cryptographic Checksums (SHA-256)

Verifying the SHA-256 hash of downloaded binaries is a critical security step to ensure that files have not been corrupted during transit or compromised by malicious actors.

Inspect the official checksum provided on the Go download page and calculate the local hash of /tmp/go.tar.gz using sha256sum.

Confirm that the generated 64-character hash matches the published checksum string exactly before proceeding with extraction.

# Calculate the SHA256 hash of the downloaded archive
sha256sum /tmp/go.tar.gz

# Expected checksum pattern: 542d21... (match against https://go.dev/dl/)

Step 4: Extracting Go to /usr/local

In accordance with standard Linux filesystem hierarchy conventions, third-party software and multi-user language runtimes are placed in /usr/local.

Before extracting a new release, remove any previous installation located at /usr/local/go to prevent leftover binary artifacts or mismatched standard library modules.

Extract the archive into /usr/local using sudo tar. This creates the root toolchain directory at /usr/local/go.

Remove the temporary downloaded tarball once extraction completes.

# Remove any previous Go installation
sudo rm -rf /usr/local/go

# Extract archive into /usr/local
sudo tar -C /usr/local -xzf /tmp/go.tar.gz

# Clean up temporary archive
rm -f /tmp/go.tar.gz

Step 5: Configuring Environment Variables (PATH and GOPATH)

To execute go commands from any terminal shell, you must add the Go binary directory (/usr/local/go/bin) to your system PATH.

Additionally, you should configure your user workspace directory via GOPATH (by default ~/go) and include ~/go/bin in your PATH so that binaries compiled via go install are immediately runnable.

For user-specific access, append the environment exports to your ~/.bashrc file. For system-wide access across all users, create an entry in /etc/profile.d/go.sh.

Apply the changes immediately to your active shell session by sourcing your profile.

# Configure environment variables in ~/.bashrc
cat <<'EOF' >> ~/.bashrc

# Go environment configuration
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
EOF

# Reload shell configuration
source ~/.bashrc

Step 6: Verifying the Go Installation and Toolchain

Confirm that your shell properly resolves the go binary and inspect the active version and environment properties.

Execute go version to verify the compiler build release.

Run go env to print all configured runtime flags, target architectures, CGO status, and compiler search paths.

# Verify Go version
go version

# Inspect Go environment paths and CGO status
go env GOPATH GOBIN GOOS GOARCH

Step 7: Building and Running a Sample Go Application

To test your newly configured Go development environment, create a simple multi-threaded application utilizing Go's native module system.

Create a new directory named ~/hello-go, initialize a Go module using go mod init, and create a main.go source file.

Write a program that uses goroutines and channels to verify that Go's runtime and compiler are fully functional.

Compile and run the program using go run main.go, or build an optimized standalone native binary using go build.

# Create project directory
mkdir -p ~/hello-go && cd ~/hello-go

# Initialize Go module
go mod init hello-go

# Create main.go source file
cat <<'EOF' > main.go
package main

import (
	"fmt"
	"runtime"
	"time"
)

func main() {
	fmt.Printf("Hello, Ubuntu 24.04! Go running on %s/%s with %d CPUs\n",
		runtime.GOOS, runtime.GOARCH, runtime.NumCPU())

	ch := make(chan string)
	go func() {
		time.Sleep(100 * time.Millisecond)
		ch <- "Goroutine completed successfully!"
	}()

	fmt.Println(<-ch)
}
EOF

# Build and execute the application
go run main.go

# Compile into an optimized standalone binary
go build -ldflags="-s -w" -o hello-app
./hello-app

Step 8: Managing Go Tools and Upgrading Releases

Modern Go projects manage dependencies using go modules (defined in go.mod and go.sum). To install third-party developer utilities, linters, or language servers (such as gopls), use go install.

When a new minor or security release of Go is published, upgrading is straightforward. Simply download the newer tarball, remove the old folder at /usr/local/go, and extract the new release into /usr/local.

Because your environment variables in ~/.bashrc point to /usr/local/go/bin, the system will immediately use the updated compiler.

# Install the official Go language server (gopls)
go install golang.org/x/tools/gopls@latest

# Install popular linter golangci-lint
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

Command 'go' not found after extracting to /usr/local/go

Resolution: This indicates that /usr/local/go/bin has not been appended to your active shell $PATH. Run export PATH=$PATH:/usr/local/go/bin in your current terminal and verify that the export is written to ~/.bashrc or /etc/profile.d/go.sh.

Permission denied errors during package installation

Resolution: Never execute sudo go build or sudo go install inside user project workspaces. If permissions are restricted, check ownership of your workspace with sudo chown -R $USER:$USER ~/go.

CGO compilation failures with missing gcc or libc headers

Resolution: If your Go application imports packages requiring CGO (C interop), ensure the native GCC toolchain is installed by running sudo apt install -y build-essential.

Security Best Practices and Hardening

Always verify the SHA-256 checksum of downloaded Go binary archives against the cryptographic hashes published on the official https://go.dev/dl/ security page.

Avoid running go build or executing Go binaries as the root user. Maintain a dedicated unprivileged user workspace for development and deployment.

Keep go.sum committed in version control alongside go.mod. The go.sum file verifies cryptographic checksums for all third-party dependencies, preventing supply chain attacks.

Regularly run govulncheck (installed via go install golang.org/x/vuln/cmd/govulncheck@latest) across your codebases to detect known CVE vulnerabilities in dependencies.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

3 FAQs
Ubuntu's official APT repositories (golang-go) frequently package older versions of Go. Installing from the official tarball ensures access to the latest compiler optimizations, language features, and security patches.
GOROOT points to the directory where Go's compiler and standard library are installed (typically /usr/local/go). GOPATH specifies your personal workspace for downloaded dependencies and compiled module binaries (typically ~/go).
To uninstall Go, remove the installation directory using sudo rm -rf /usr/local/go, remove Go exports from ~/.bashrc, and delete your module cache using rm -rf ~/go.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Cloud & DevOps•

How to Close File Descriptors Above 9 in Dash Shell

Attempting to close a file descriptor above 9 in Dash using exec 10<&- results in a 10: not found error because Dash's POSIX lexer only recognizes single-digit file descriptors (0–9) in redirection operators. This guide explains the exact parser limitation, why FDs 10+ are reserved for internal shell state, and how to safely close inherited file descriptors using close_range, Python, or Perl wrappers.

RR
Rajesh Rai
Read More
Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout