How to Install Go on Ubuntu 24.04

Go is an open-source well-liked programming language by Google. It is used to build secure, simple, and flexible applications and microservices with strong concurrency support and a built-in robust library. Go language is quite similar to C language and is popular for its reliability and efficiency. With the strong ecosystem of API and tools on service providers, it is well suited for cloud-based applications and services, web development, and command line interfaces. All major operating systems can install Go.

This tutorial will demonstrate the following outline:

How to Install Go on Ubuntu 24.04 Using APT

The APT utility manages Linux packages on almost all Debian-based distributions. It is used to add, update, or remove packages. To install Go on Ubuntu 24 from Advanced Package Tool (APT), follow the below demonstration.

Step 1: Update APT Repository

First, update Ubuntu’s APT repository through the “apt update” command:

sudo apt update

Step 2: Install Go

Next, install the “golang-go” package on Ubuntu 24. For this purpose, go through the below command:

sudo apt install golang-go -y

In the above command, “golang-go” is a package that installs Go on the system, and the “-y” option allows the process to use the required additional disk space for installation:

Step 3: Verification

To check if Go is installed on Ubuntu or not, check the Go version through the below command:

go version

The output shows that we have effectively installed “go1.22.2” on Ubuntu 24.04:

Bonus Tip: How to Uninstall Go Through APT

Occasionally, users need to remove the Go from Ubuntu to debug the Go installation, switch the development environment, or update the Go package. To uninstall Go which is installed through APT, follow the below steps.

Step 1: Remove Go Package

First, remove the Go package from the system through the “apt remove golang-go” command:

sudo apt remove golang-go

Step 2: Remove Go Additional Configuration

Clean the Ubuntu by removing the additional dependencies installed by the Go package:

sudo apt autoremove golang-go

Step 3: Remove Go Installation Directory

Lastly, remove the Go installation directory using the below command:

sudo rm -rf /usr/local/go

How to Install Go on Ubuntu 24.04 Using Binary

The Binary files in Ubuntu contain the application or package executables. These binary scripts or files can be archived that contain other files or package executables. To install Go from the binary script on Ubuntu 24.04, download the script through the “wget” command. 

For illustrations, check out the listed steps:

Step 1: Install “wget”

The “wget” utility is utilized to access or download the file or content from the web pages. To download the Go official binary, first install the “wget” package on the system through mentioned command:

sudo apt install wget

Step 2: Choose Go Binary

Next, navigate to Go official “All releases” page and choose the binary you want to download:

Step 3: Download Go Binary 

Next, download the Binary file of the Go application through the below command. Replace the Binary name with your chosen version:


In the above command, we have downloaded the latest version of Go:

Step 4: Extract the Archive 

Next, extract the Go binary in the “/usr/local” directory to install Go on Ubuntu 24.04:

sudo tar -C /usr/local -xzf go1.22.2.linux-amd64.tar.gz

This will extract the “go” binary on the specified path:

Step 5: Add Go to Ubuntu Path

Now, the user needs to update the environment variables to add the Go to the system path to make the Go utility usable. For this purpose, export the Go installation path either in the $HOME/.profile or /etc/profile file.

For demonstration, we are updating the “$HOME/.profile” file in the nano editor:

sudo nano ~/.profile

Move to the end of the file and paste the following line:

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

Press “CTRL+S” to save the change and exit the editor using the “CTRL+X” key.

Reload the configuration of the “~/.profile” file:

source ~/.profile

This may require a reboot of the system to apply changes. Restart the Ubuntu through the “reboot” command:

sudo reboot

Step 6: Verification

For the confirmation, check the Go version:

go version

The output shows that we have successfully installed the Go on Ubuntu 24:

Bonus Tip: How to Uninstall Go by Removing Installation Directory

To remove the Go that is installed through binary, simply remove the Go installation directory:

sudo rm -rf /usr/local/go

How to Install Go on Ubuntu  24.04 Using Snapd

The Snapd is a Linux utility utilized to manage the Linux snaps. The snaps are packages, applications, or tools that execute on Linux distributions. To install Go on Ubuntu 24.04 through snapd, utilize the following command:

sudo snap install go --classic

For verification, check out the Go version through the “go version” command:

go version

Bonus Tip: How to Uninstall Go Through Snapd

To remove the Go which is installed through the snapd utility, utilize the “sudo snap remove go” command:

sudo snap remove go

This will remove the Go package from the system:

That is all about installation and removing Go from Ubuntu 24.04. Let’s move ahead to use Go on Ubuntu 24.04.

How to Use Go on Ubuntu 24.04

To get started with Go on Ubuntu 24.04, first create a simple program file named “demo.go”:

sudo nano demo.go

Add the basic Golang program that shows a simple string on the server:

package main

import (

func handler (w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, "ItsLinuxFoss Tutorial on Golang Installation")
func main () {
        http.HandleFunc("/", handler)
        log.Fatal(http.ListenAndServe("", nil))

In the above code, we will print the simple textual string on port “8080”:

Next, compile and execute the Golang program file through the “go run <file-name>” command:

go run demo.go

For confirmation, navigate to “http://localhost:8080” and check if the Golang program file is executing or not:

This is all about Golang on Ubuntu 24.04.


To install Go on Ubuntu 24.04, you can either install it through APT using the “sudo apt install golang-go” command, through Golang binary, or Snapd using the “sudo snap install go –classic” command. To execute the Go program on Ubuntu, simply utilize the “go run <program-file>” command. This write-up has illustrated the methods to install and uninstall Go (Golang) from Ubuntu 24.04.