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

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

Method 1: Install GO on Ubuntu 24.4 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

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

Step 3: Verify the Installation

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

sudo go version

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

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")
}

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

sudo go run goapp.go

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 languages and save it in the “go.tar.gz” file:

wget https://go.dev/dl/go1.22.1.linux-amd64.tar.gz -O go.tar.gz

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

Step 3: Open the Extracted GO Directory

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

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: 

Step 5: Open “.profile” File

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

nano ~/.profile

Step 6: Configure Environment Variable

Add the following statements to configure the environment variables for the GO programming languages, After the required modifications, press “CTRL + X” to save changes. Enter the “Y” button for “yes” to the prompts and then hit the “Enter” button to exit the current interface:

export GOROOT=/home/ubuntuuser/Desktop/go
export GOPATH=$Home/GO
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Step 7: Refresh “.profile” file

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

source ~/.profile

Step 8: Verify the Installations

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

go version

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

The Snap packet manager download, installs, remove, or update different software and packages in the 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 the permissions to access the directories and files outside of its confined environment:

sudo snap install go --classic

Step 2: Verify the Installation

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

sudo go version

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

nano gosample.go

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")
}

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

sudo go run gosample.go

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 the curl from the Apt package manager:

sudo apt install curl

Step 2: Download and Install Go via Curl

The following command downloads and installs the Go programming language using the Curl command. The “– O” option downloads and saves the file to the system with the same name as it has on the server:

curl -O https://storage.googleapis.com/golang/go1.22.1linux-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 late in this article:

Step 5: Configure Environment Variables

The following command appends the specified environment variable to the .profile file located in the home directory:

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

Similarly, we will configure the Path variable by providing the copied path to it using the export statement. The environment variables will be written to the “.profile” file: 

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

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 as shown in the code below: 

go version

That is all from this guide.

Conclusion 

The Go Programming language provides a simplified approach to developers for implementing, testing, debugging, and deploying applications. Such applications are compatible with various platforms such as clouds, servers, Linux-based distributions, etc. To install the Go on Ubuntu 24.04, use Apt or Snap packet manage or use the wget or curl command line utilities as shown in this article. In this article, we have installed the Go on Ubuntu 24.04 using different commands.