Hot Summer Sale - up to 36% OFF

How to Install Go on Ubuntu 24.04: Step-by-Step

How to Install Go on Ubuntu 24.04: Step-by-Step
Published on Jun 23, 2025 Updated on Jun 23, 2025

The Google team developed the statically typed compiled programming language known as Go or Golang. Go is popular among developers who need to create scalable applications because of its efficient coding structure and robust programming model, which suits cloud-based programs and distributed system development. This guide provides all the necessary steps to install Go on Ubuntu 24.04 for those who wish to start their Go development journey.

#Why Go on Ubuntu?

The platform provided by Ubuntu ensures stability and reliability for developers working in the environment. The combined strength of Go's cross-platform capabilities and Ubuntu makes a powerful combination for creating diverse applications. Through the apt package management system, Ubuntu provides easy software installation alongside a large community base for user assistance when needed.

#Prerequisites:

  • An Ubuntu 24.04 system with sudo privileges.
  • A stable internet connection.
  • Basic familiarity with the command line.

Deploy and scale your projects with Cherry Servers' cost-effective dedicated or virtual servers. Enjoy seamless scaling, pay-as-you-go pricing, and 24/7 expert support—all within a hassle-free cloud environment.

#Installing Go on Ubuntu 24.04

Go installation for Ubuntu 24.04 can be achieved through multiple pathways. This guide will focus on the official Go distribution method since it offers the most reliable and current version.

#Method 1: Installing Go from the official distribution

This method ensures you get the latest stable Go release directly from the official Go website.

#Step 1: Download the Go archive

Open a terminal and press Ctrl + Alt + T or search for *Terminal in the applications menu. Navigate to your home directory:

Command Line
cd ~

Download the latest Go archive. Visit the official [Go downloads page] (https://go.dev/dl/) and identify the latest stable version for Linux (usually a .tar.gz file). Replace version with the actual version number in the following command:

For instance, the current latest version is 1.24.2, the command would be:

Command Line
wget https://go.dev/dl/go1.24.2.linux-amd64.tar.gz
Output--2025-04-01 22:26:30--  https://go.dev/dl/go1.24.2.linux-amd64.tar.gz
Resolving go.dev (go.dev)... 216.239.36.21, 216.239.38.21, 216.239.34.21, ...
Connecting to go.dev (go.dev)|216.239.36.21|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://dl.google.com/go/go1.24.2.linux-amd64.tar.gz [following]
--2025-04-01 22:26:30--  https://dl.google.com/go/go1.24.2.linux-amd64.tar.gz
Resolving dl.google.com (dl.google.com)... 142.250.196.174, 2404:6800:4007:809::200e
Connecting to dl.google.com (dl.google.com)|142.250.196.174|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 74762151 (71M) [application/x-gzip]
Saving to: ‘go1.24.2.linux-amd64.tar.gz’

go1.24.2.linux-ar 100%[=============>]  71.30M  23.1MB/s	in 3.1s    

2025-04-01 22:26:34 (23.1 MB/s) - ‘go1.24.2.linux-amd64.tar.gz’ saved [74762151/74762151]

#Step 2: Extract the archive

Save the downloaded archive in the /usr/local directory, the standard software installation location.

Command Line
sudo tar -C /usr/local -xzf go1.24.2.linux-amd64.tar.gz

ls -l /usr/local/go*
Outputtotal 72
drwxr-xr-x  2 root root  4096 Mar 27 00:39 api
drwxr-xr-x  2 root root  4096 Mar 27 00:39 bin
-rw-r--r--  1 root root	52 Mar 27 00:39 codereview.cfg
-rw-r--r--  1 root root  1337 Mar 27 00:39 CONTRIBUTING.md
drwxr-xr-x  3 root root  4096 Mar 27 00:39 doc
-rw-r--r--  1 root root   505 Mar 27 00:39 go.env
drwxr-xr-x  5 root root  4096 Mar 27 00:39 lib
-rw-r--r--  1 root root  1453 Mar 27 00:39 LICENSE
drwxr-xr-x  8 root root  4096 Mar 27 00:39 misc
-rw-r--r--  1 root root  1303 Mar 27 00:39 PATENTS
drwxr-xr-x  4 root root  4096 Mar 27 00:39 pkg
-rw-r--r--  1 root root  1454 Mar 27 00:39 README.md
-rw-r--r--  1 root root   426 Mar 27 00:39 SECURITY.md
drwxr-xr-x 56 root root  4096 Mar 27 00:39 src
drwxr-xr-x 28 root root 12288 Mar 27 00:39 test
-rw-r--r--  1 root root	35 Mar 27 00:39 VERSION

#Step 3: Configure environment variables

The ~/.profile file requires editing because it enables login-dependent environment variable configuration.

Command Line
sudo nano ~/.profile

The following lines must be appended at the end of the file because they both add the Go binary directory path to the PATH variable while also establishing the GOPATH and GOROOT variables.

export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
  • GOROOT: Specifies the root directory of the Go installation.
  • GOPATH: The workspace directory for Go projects and dependencies should be specified here.
  • PATH: Adds the Go binary directory to your system's executable path.

Save the file and exit. The changes become active by either performing a new login or executing the below command to source the ~/.profile file:

Command Line
source ~/.profile

#Step 4: Verify the installation

Check the Go version:

Command Line
go version

This command should display the installed Go version.

Outputgo version go1.24.2 linux/amd64

Check the Go environment:

Command Line
go env

This command will display the Go environment variables, including GOROOT and GOPATH.

OutputAR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='0'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='x64'
GOAMD64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/ubuntu/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/ubuntu/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1563029445=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/home/ubuntu/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/ubuntu/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/ubuntu/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.2'
GOWORK=''
PKG_CONFIG='pkg-config'

#Method 2: Using apt (Less recommended)

Ubuntu's repositories might contain an older Go version. While this method is simpler, it might not provide the latest features and security updates.

Firstly, update the package list:

Command Line
sudo apt update

Install Go using apt:

Command Line
sudo apt install golang-go
OutputReading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu g++ g++-13
  g++-13-x86-64-linux-gnu g++-x86-64-linux-gnu gcc gcc-13 gcc-13-x86-64-linux-gnu
  gcc-x86-64-linux-gnu golang-1.22-go golang-1.22-src golang-src libasan8
  libbinutils libcc1-0 libctf-nobfd0 libctf0 libgcc-13-dev libgprofng0 libhwasan0
  libitm1 liblsan0 libpkgconf3 libquadmath0 libsframe1 libstdc++-13-dev libtsan2
  libubsan1 pkg-config pkgconf pkgconf-bin
Suggested packages:
  binutils-doc gprofng-gui g++-multilib g++-13-multilib gcc-13-doc gcc-multilib
  make autoconf automake libtool flex bison gcc-doc gcc-13-multilib gcc-13-locales
  gdb-x86-64-linux-gnu bzr | brz git mercurial subversion libstdc++-13-doc
The following NEW packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu g++ g++-13
  g++-13-x86-64-linux-gnu g++-x86-64-linux-gnu gcc gcc-13 gcc-13-x86-64-linux-gnu
  gcc-x86-64-linux-gnu golang-1.22-go golang-1.22-src golang-go golang-src libasan8
  libbinutils libcc1-0 libctf-nobfd0 libctf0 libgcc-13-dev libgprofng0 libhwasan0
  libitm1 liblsan0 libpkgconf3 libquadmath0 libsframe1 libstdc++-13-dev libtsan2
  libubsan1 pkg-config pkgconf pkgconf-bin
0 upgraded, 34 newly installed, 0 to remove and 0 not upgraded.
Need to get 45.7 MB/100 MB of archives.
After this operation, 431 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Ign:1 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 golang-1.22-src all 1.22.2-2ubuntu0.2
Get:3 http://archive.ubuntu.com/ubuntu noble/main amd64 golang-src all 2:1.22~2build1 [5078 B]
Get:4 http://archive.ubuntu.com/ubuntu noble/main amd64 golang-go amd64 2:1.22~2build1 [43.9 kB]
Get:5 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 binutils-common amd64 2.42-4ubuntu2 [239 kB]
Get:6 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libsframe1 amd64 2.42-4ubuntu2 [14.8 kB]
Get:7 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libbinutils amd64 2.42-4ubuntu2 [572 kB]
Get:8 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libctf-nobfd0 amd64 2.42-4ubuntu2 [97.1 kB]
Get:9 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libctf0 amd64 2.42-4ubuntu2 [94.5 kB]
Get:10 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libgprofng0 amd64 2.42-4ubuntu2 [851 kB]
Get:11 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 binutils-x86-64-linux-gnu amd64 2.42-4ubuntu2 [2469 kB]
Get:12 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 binutils amd64 2.42-4ubuntu2 [18.0 kB]
Get:13 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libcc1-0 amd64 14-20240412-0ubuntu1 [47.7 kB]
Get:14 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libitm1 amd64 14-20240412-0ubuntu1 [28.9 kB]
Get:15 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libasan8 amd64 14-20240412-0ubuntu1 [3024 kB]
Get:16 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 liblsan0 amd64 14-20240412-0ubuntu1 [1313 kB]
Get:17 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libtsan2 amd64 14-20240412-0ubuntu1 [2736 kB]
Get:18 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libubsan1 amd64 14-20240412-0ubuntu1 [1175 kB]
Get:19 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libhwasan0 amd64 14-20240412-0ubuntu1 [1632 kB]
Get:20 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libquadmath0 amd64 14-20240412-0ubuntu1 [153 kB]
Get:21 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libgcc-13-dev amd64 13.2.0-23ubuntu4 [2688 kB]
Get:22 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 gcc-13-x86-64-linux-gnu amd64 13.2.0-23ubuntu4 [21.9 MB]
Get:23 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 gcc-13 amd64 13.2.0-23ubuntu4 [482 kB]
Get:24 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 gcc-x86-64-linux-gnu amd64 4:13.2.0-7ubuntu1 [1212 B]
Get:25 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 gcc amd64 4:13.2.0-7ubuntu1 [5018 B]
Get:26 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libstdc++-13-dev amd64 13.2.0-23ubuntu4 [2399 kB]
Get:27 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 g++-13-x86-64-linux-gnu amd64 13.2.0-23ubuntu4 [12.5 MB]
Get:28 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 g++-13 amd64 13.2.0-23ubuntu4 [14.5 kB]
Get:29 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 g++-x86-64-linux-gnu amd64 4:13.2.0-7ubuntu1 [964 B]
Get:30 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 g++ amd64 4:13.2.0-7ubuntu1 [1100 B]
Get:31 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 libpkgconf3 amd64 1.8.1-2build1 [30.7 kB]
Get:32 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 pkgconf-bin amd64 1.8.1-2build1 [20.7 kB]
Get:33 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 pkgconf amd64 1.8.1-2build1 [16.8 kB]
Get:34 cdrom://Ubuntu 24.04.1 LTS _Noble Numbat_ - Release amd64 (20240827.1) noble/main amd64 pkg-config amd64 1.8.1-2build1 [7264 B]
Fetched 49.0 kB in 3s (15.4 kB/s)


Selecting previously unselected package golang-1.22-src.
(Reading database ... 212379 files and directories currently installed.)
Preparing to unpack .../golang-1.22-src_1.22.2-2ubuntu0.3_all.deb ...
Unpacking golang-1.22-src (1.22.2-2ubuntu0.3) ...
Selecting previously unselected package golang-1.22-go.
Preparing to unpack .../golang-1.22-go_1.22.2-2ubuntu0.3_amd64.deb ...
Unpacking golang-1.22-go (1.22.2-2ubuntu0.3) ...
Setting up golang-1.22-src (1.22.2-2ubuntu0.3) ...
Setting up golang-src (2:1.22~2build1) ...
Setting up golang-1.22-go (1.22.2-2ubuntu0.3) ...
Setting up golang-go:amd64 (2:1.22~2build1) …

Verify the installation:

Command Line
go version
Outputgo version go1.22.2 linux/amd64

Note: If you install Go using apt, you might need to manually configure the GOPATH and PATH variables as described in Method 1.

#Writing your first Go program

Let’s run a simple Go program. Create a new directory for your project:

Command Line
mkdir -p ~/go/src/hello
cd ~/go/src/hello

Create a file named hello.go:

Command Line
nano hello.go

Add the following code to hello.go:

package main
import "fmt"

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

Save the file and exit. Run the program using the command below:

Command Line
go run hello.go
OutputHello, Go!

This will output "Hello, Go!" to the terminal.

Running go program

#Building and installing the program

You can also build and run an executable file of the program. To build the program, run the command below:

Command Line
go build hello.go
ls

This will create an executable file named hello in the current directory.

go build Run the executable:

Command Line
./hello

This will give the below output:

OutputHello, Go!

Running go build executable

You can also compile and install a Go package to your system's $GOPATH/bin directory, making the compiled binary available system-wide. To install the program, run the command below:

Command Line
go install hello.go

This will install the executable to the $GOPATH/bin directory, making it available from anywhere in your system.

Run the installed program:

Command Line
 hello

This will give the below output:

OutputHello, Go!

go install

You have successfully installed Go on Ubuntu 24.04!

#Conclusion

Installing Go on the Ubuntu 24.04 system requires simple steps to perform. The steps presented in this guide enable quick setup of your Go development environment so you can begin developing robust applications. Using the official distribution provides you with the current features and security updates. Setting up your Go development environment requires the correct configuration of environment variables, especially GOPATH and PATH, to streamline your Go development workflow. Your Ubuntu 24.04 system can now start producing remarkable applications after installing and setting up Go. Happy coding!

Cloud VPS Hosting

Starting at just $3.24 / month, get virtual servers with top-tier performance.

Share this article

Related Articles

Published on Jun 7, 2021 Updated on Jun 29, 2022

AlmaLinux Review: a CentOS Clone Supported by CloudLinux

AlmaLinux is an open-source Linux distribution focused on long-term stability, that is a 1:1 binary compatible fork of Red Hat Enterprise Linux (RHEL)

Read More
Published on May 31, 2022 Updated on May 5, 2023

A Complete Guide to Linux Bash History

Learn how to work with Bash history to become more efficient with any modern *nix operating system.

Read More
Published on Jan 26, 2022 Updated on Jun 15, 2023

How to Use Cron to Automate Linux Jobs on Ubuntu 20.04

Learn how to use Cron - the most popular Linux workload automation tool that is widely used in Linux community - to automate Linux jobs on Ubuntu 20.04.

Read More
We use cookies to ensure seamless user experience for our website. Required cookies - technical, functional and analytical - are set automatically. Please accept the use of targeted cookies to ensure the best marketing experience for your user journey. You may revoke your consent at any time through our Cookie Policy.
build: 2d9b4f78d.1247