How to Install Go on Ubuntu 26.10
Go (Golang) is an open-source programming language developed by Google. It is widely used for building command-line tools, cloud applications, APIs, and server-side applications.
This guide covers two methods to install Go on Ubuntu 26.10:
- Installing Go using the official precompiled binary.
- Installing the latest Go version from source.
Method 1: Install Go Using the Official Binary
This method installs Go using the official precompiled binary and is recommended for most users.
Step 1: Update the System
Update the package lists and install the required utilities.
sudo apt update
sudo apt install -y wget ca-certificates
Step 2: Download Go
At the time of writing this guide, the latest stable Go version is 1.27.3.
Download the official Linux AMD64 archive:
cd /tmp
wget https://go.dev/dl/go1.27.3.linux-amd64.tar.gz
Verify the downloaded archive using its SHA-256 checksum:
echo "65efbc80fdc1fa2cd2631cad5b481777a68e8725f34e89f50fc6ac714e379b40 go1.27.3.linux-amd64.tar.gz" | sha256sum -c -
Output:
go1.27.3.linux-amd64.tar.gz: OK
For other architectures or newer releases, check the official Go downloads page.
Step 3: Install Go
Remove any previous Go installation from /usr/local/go and extract the downloaded archive.
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf /tmp/go1.27.3.linux-amd64.tar.gz
Step 4: Configure Environment Variables
Add Go to the system PATH for your user.
echo 'export PATH=/usr/local/go/bin:$HOME/go/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
Create the default workspace directory:
mkdir -p ~/go/bin ~/go/src ~/go/pkg
Step 5: Verify the Installation
Check the installed Go version:
go version
Expected output:
go version go1.27.3 linux/amd64
Check the Go environment:
go env GOROOT GOPATH
Method 2: Install the Latest Go from Source
This method compiles Go from its source code. It is useful when you want to build Go yourself or need a source-based installation.
At the time of writing this guide, the latest stable Go version is 1.27.3.
Step 1: Install Build Dependencies
Update the package lists and install the required build tools.
sudo apt update
sudo apt install -y build-essential gcc git wget ca-certificates
Step 2: Install the Bootstrap Go Compiler
Go is written in Go, so building a new version requires an existing Go compiler.
In this guide, Go 1.26.0 is used as the bootstrap compiler.
Download and install the bootstrap compiler:
cd /tmp
wget https://go.dev/dl/go1.26.0.linux-amd64.tar.gz
sudo mkdir -p /usr/local/go-bootstrap
sudo tar -C /usr/local/go-bootstrap --strip-components=1 -xzf go1.26.0.linux-amd64.tar.gz
Verify the bootstrap compiler:
/usr/local/go-bootstrap/bin/go version
Step 3: Download the Go Source Code
Download the Go 1.27.3 source archive:
cd /tmp
wget https://go.dev/dl/go1.27.3.src.tar.gz
Verify the source archive using its official SHA-256 checksum:
echo "6e7749035cf360f06b2575d162ea79df9fda8ef671889e5c375f8e50777f26bb go1.27.3.src.tar.gz" | sha256sum -c -
The output should show OK.
Step 4: Extract the Source Code
Extract the source code into a separate directory:
sudo mkdir -p /usr/local/go1.27.3-src
sudo tar -C /usr/local/go1.27.3-src --strip-components=1 -xzf /tmp/go1.27.3.src.tar.gz
Step 5: Compile Go from Source
Set the bootstrap compiler environment variable and build Go.
cd /usr/local/go1.27.3-src/src
sudo env GOROOT_BOOTSTRAP=/usr/local/go-bootstrap ./make.bash
The compilation process can take several minutes, depending on the server's resources.
After the build completes successfully, move the compiled toolchain into its final location:
sudo mv /usr/local/go1.27.3-src /usr/local/go
Step 6: Configure Environment Variables
Add Go to the PATH:
echo 'export PATH=/usr/local/go/bin:$HOME/go/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
Create the Go workspace directories:
mkdir -p ~/go/bin ~/go/src ~/go/pkg
Step 7: Verify the Source Installation
Run the following command:
go version
Expected output:
go version go1.27.3 linux/amd64
Step 8: Test Go with a Sample Program
This step applies to either installation method.
Create a sample Go program:
cat > hello.go <<'EOF'
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
EOF
Run the program:
go run hello.go
Expected output:
Hello, World!
Conclusion
You have installed Go on Ubuntu 26.10 using either the official binary or by compiling the source code.
For most users, the official binary installation is the simplest option. The source installation is useful when you specifically need to compile Go yourself.
To check for newer releases, visit the official Go downloads page and the Go release history.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS