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.

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.
- Prerequisites and Supported Releases
- Step 1: Updating System Packages and Installing Download Utilities
- Step 2: Downloading the Official Go Binary Archive
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.
Install the latest stable release of the Go (Golang) programming language on Ubuntu 24.04 LTS from official upstream archives, set up environment variables, and compile your first application.
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 LTSwith terminal access. - A non-root user account configured with
sudoadministrative privileges. - Basic familiarity with the Linux command line,
curl, andtar. - 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.
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.
# 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.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
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).sudo rm -rf /usr/local/go, remove Go exports from ~/.bashrc, and delete your module cache using rm -rf ~/go.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
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.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides




Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!