Go or GOlang is a popular open-source programming language developed by Google. The primary objective of this language is the efficiency and reliability which make it effective for designing and implementing microservices with ease. GO is an effective language due to its efficiency and concurrency. Having it installed on Ubuntu 24.04 can help the developers in building, compiling, and testing several Go applications.

Quick answer

You can install Go on Ubuntu 24.04 with APT, Snap, wget, or curl. Use APT for the Ubuntu-packaged version, Snap for a quick install, or the official download method when your project needs a newer Go release.

In this article, we will cover different methods for installing GO on Ubuntu 24.04.

Method 1: Install GO on Ubuntu 24.04 Using APT Package Manager

APT or Advanced Package Tools is a command-line utility that provides several software packages for downloading, installing, updating, or removing. It is compatible with different Debian distributions such as LinuxMint, Ubuntu, etc. The APT package manager can be used to install the GO on Ubuntu 24.04. The steps are as follows:

Step 1: Update APT Package Manager

The following command updates the package lists inside a repository with the superuser privilegessudo“. The flag “-y” indicates the “yes” response to all the prompts:

sudo apt update -y
Terminal output of sudo apt update -y on Ubuntu 24.04

Step 2: Install GO on Ubuntu 24.04

Provide the following command to the Ubuntu 24.04 terminal to install the GO from the APT package manager using superuser privileges:

sudo apt install golang-go
Terminal output of sudo apt install golang-go on Ubuntu 24.04

Step 3: Verify the Installation

The following command verifies the successful installation of the GO on Linux distribution:

sudo go version
Terminal output of sudo go version after APT installation on Ubuntu 24.04

The following command will create or edit the file “goapp.go“. The “goapp.go” file will be used to create and execute the GO application:

nano goapp.go
Nano editor opening goapp.go file on Ubuntu 24.04

Append the following lines of code to the “goapp.go” file. Press CTRL+X to apply and save changes. Hit “Y” from the keyboard followed by “Enter” afterward:

package main
import "fmt"
func main()
{
fmt.Printf("My sample Go app\n")
}
Go hello world code written in goapp.go using nano editor

To execute the “goapp.go” file, provide the following command to the terminal:

sudo go run goapp.go
Terminal output of sudo go run goapp.go printing hello world

Method 2: Install Go on Ubuntu 24.04 Using Wget Command-Line Utility

Wget is a command-line utility that downloads files from the web using network protocols such as HTTP, FTP, etc. This command utility helps download files when facing an unstable network issue. To download the GO via the Wget on Ubuntu 24.04, follow the below-mentioned steps.

Step 1: Download the Latest GO Version Using Wget

The “wget” is a command utility that is used to fetch and download the software from the internet. The command given below downloads the GO programming language and saves it as “go.tar.gz“:

wget https://go.dev/dl/go1.22.1.linux-amd64.tar.gz -O go.tar.gz
Terminal output of wget downloading Go 1.22.1 to go.tar.gz on Ubuntu 24.04

Step 2: Extract the Contents Using tar.gz

Provide the following command to the terminal to extract and display the contents of the “go.tar.gz” file:

tar -xvzf go.tar.gz
Terminal output of tar -xvzf extracting Go tar.gz on Ubuntu 24.04

Step 3: Open the Extracted GO Directory

Navigate to the location of the extracted “GO” folder. Right-click on the folder to open it:

File manager showing extracted go directory on Ubuntu 24.04

Step 4: Copy Directory Path

Copy the path of the extracted GO directory as shown in the image below. This path will be used later to set the environment variables:

File manager showing directory path of extracted Go folder

Step 5: Open “.profile” File

The command “nano ~/.profile” opens the “.profile” file located in the home directory (~):

nano ~/.profile
Nano editor opening ~/.profile file on Ubuntu 24.04

Step 6: Configure Environment Variable

Add the following statements to configure the environment variables for the GO programming language. Replace the GOROOT path with your actual extracted directory path. After the required modifications, press “CTRL + X” to save changes. Enter “Y” for yes and then hit “Enter” to exit:

export GOROOT=/home/ubuntuuser/Desktop/go
export GOPATH=$HOME/GO
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
Nano editor showing GOROOT GOPATH and PATH variables added to .profile

Step 7: Refresh “.profile” file

Refresh the “.profile” file by using the following command:

source ~/.profile
Terminal output of source ~/.profile refreshing environment on Ubuntu 24.04

Step 8: Verify the Installation

The following command displays the current GO version installed on the Linux distribution using Ubuntu 24.04:

go version
Terminal showing go version after wget-based Go installation on Ubuntu 24.04

Method 3: Install GO on Ubuntu 24.04 Using Snap Packet Manager

The Snap packet manager downloads, installs, removes, or updates different software and packages in Debian-based distributions. It works exactly like the apt or yum packet managers. The steps are given as follows to install the Go programming language using the Snap packet manager:

Step 1: Install Go using Snap

The following statement installs the GO programming language from the Snap package manager. The “–classic” flag installs the package with permissions to access directories and files outside of its confined environment:

sudo snap install go --classic
Terminal output of sudo snap install go --classic on Ubuntu 24.04

Step 2: Verify the Installation

To verify if the GO language has been installed on Linux, use the following command:

sudo go version
Terminal showing sudo go version after Snap installation on Ubuntu 24.04

The command given below creates and opens the file “gosample.go” using the nano text editor:

nano gosample.go
Nano editor opening gosample.go file on Ubuntu 24.04

Append the given code to the “gosample.go” file that prints the following message specified in the “Printf()” method:

package main
import "fmt"
func main(){
fmt.Printf("Installing GO using the Snap\n")
}
Go sample code written in gosample.go using nano editor

The “gosample.go” file is executed using the command given as follows:

sudo go run gosample.go
Terminal output of sudo go run gosample.go printing Snap install message

Method 4: Install GO on Ubuntu 24.04 Using Curl Utility

The “curl” is a command-line utility that provides support for various Linux-based distributions including Ubuntu. The curl command transfers the data to or from the server using different protocols such as HTTP, HTTPS, etc. In Ubuntu, the curl command is first installed using the apt package manager as it is not readily available by default. You can then use this utility to download and install the Go on Ubuntu 24.04. The steps are mentioned below:

Step 1: Install Curl

The following command installs curl from the apt package manager:

sudo apt install curl
Terminal output of sudo apt install curl on Ubuntu 24.04

Step 2: Download and Install Go via Curl

The following command downloads the Go programming language tarball using curl. The “-O” option saves the file with the same name as on the server:

curl -O https://storage.googleapis.com/golang/go1.22.1.linux-amd64.tar.gz

Step 3: Extract the Contents of the File

The following command extracts the contents of the downloaded Go file:

tar -xvzf go1.22.1.linux-amd64.tar.gz

Step 4: Copy the File Path

Navigate to the location of the extracted directory and right-click on it to open it. Copy the path of the file as it is required later in this article:

File manager showing path bar of extracted Go directory
File manager showing extracted Go folder on desktop

Step 5: Configure Environment Variables

The following command appends the GOPATH environment variable to the .profile file in the home directory. Replace the path with your actual extracted directory location:

echo "export GOPATH=$HOME//home/usr/Desktop/go" >> ~/.profile

Similarly, configure the PATH variable using the export statement:

echo "export PATH=$PATH://usr/local/go/bin:$GOPATH/bin" >> ~/.profile

Step 6: Refresh the profile file

Refresh the contents of the .profile file by using the following statement in Ubuntu 24.04:

source ~/.profile
Terminal output of source ~/.profile for curl-installed Go on Ubuntu 24.04

Step 7: Verify the Installation

For verification, use the following command. If the Go programming language has been successfully installed, it will return the version of the Go installed on Ubuntu 24.04:

go version
Terminal showing go version after curl-based Go installation on Ubuntu 24.04

How to remove Go from Ubuntu 24.04

How to remove Go depends on which installation method you used:

Install method Remove command
APT sudo apt remove golang-go && sudo apt autoremove
Snap sudo snap remove go
wget or curl (tarball) sudo rm -rf /usr/local/go then remove the PATH lines from ~/.profile

After removal, run go version to confirm the command is no longer found.

Which Go install method should you choose?

APT is convenient and stable, but it may not always provide the newest Go release. Snap is simple for desktop or test systems, while the official tarball method is better when a project requires a specific Go version.

After installation, run go version. If the command is not found, check the PATH setup before installing extra tools or moving on to application work.

Related Ubuntu 24.04 guides