How to Install GO on Ubuntu 24.04

Go, or Golang is a programming language created by Google. It has simple syntax thus its easy to learn.  Go is ideal for modern software projects, including developing web servers, cloud services, and network tools.

This post will explain different methods to install the Go programming language on the Ubuntu 24.04 system.

How to Install GO on Ubuntu 24.04?

You will learn these topics through this article:

How to Set up GO on Ubuntu 24.04?

Method 1: How to Configure Go from APT on Ubuntu 24.04?

Method 2: How to Set up Go from Snap on Ubuntu 24.04?

Method 3: How to Install Go from Binary (.tar) on Ubuntu 24.04?

How to Uninstall Go from Ubuntu 24.04?

Method 1: How to Uninstall Go from Ubuntu 24.04 using APT?

Method 2: How to Remove Go from Ubuntu 24.04 using Snap?

Method 3: How to Uninstall Go from Ubuntu 24.04 Manually?

Step 1: Update the System Repository

The following script will update your system repository. This will improve system performance, ensuring that your system applications run smoothly:

Update the System Repository
Update the System Repository

As shown above, this command refreshes your system repository and upgrades installed packages if needed.

How to Set up GO on Ubuntu 24.04?

The following methods will be presented to install the Go programming language on Ubuntu 24.04.

Method 1: How to Configure Go from APT on Ubuntu 24.04?

In this method, you will see how to install Go using APT.

Step 1: Install Go via “APT”

Install the Go package on your Ubuntu 24.04 system from the APT package manager using this command:

Configure Go from APT on Ubuntu 24.04
Configure Go from APT on Ubuntu 24.04

APT will fetch the files and associated dependencies and install them on your Ubuntu 24.04 machine without requiring additional commands.

Step 2: Go Version

The installed Go package can be confirmed using the “version” option:

Configure Go from APT on Ubuntu 24.04

Here, you can see that Go 1.22.2 has been installed on your Linux-based Ubuntu 24.04 system.

Method 2: How to Set up Go from Snap on Ubuntu 24.04?

Use the Snap command to install the Go package on Ubuntu 24.04.

Step 1: Install Go using “snap”

You can utilize the Snap package manager to install the Go package on your Ubuntu 24.04 operating system:

Set up Go from Snap on Ubuntu 24.04

When the installation is finished, the Go version will be displayed, such as 1.23.0 on your screen, confirming the successful installation.

Step 2: Add “Go” to the PATH Variable

After you have configured the Go package, Let’s edit the “.profile” file to add “Go” to PATH variable:

Set up Go from Snap on Ubuntu 24.04

Inside the “.profile” file, add the following one-liner script to the end:

Set up Go from Snap on Ubuntu 24.04

After updating the “.profile” file, return to the terminal prompt using Ctrl+S and Ctrl+X.

Step 3: Reload the “.profile” File

Apply the changes by reloading the “.profile” file:

Set up Go from Snap on Ubuntu 24.04

This command will reload the “.profile” file without rebooting your machine.

Method 3: How to Install Go from Binary (.tar) on Ubuntu 24.04?

The Go programming language can also be installed from the binary (.tar) file.

Step 1: Access the “Go” Official web page

You can download the stable release of Go from its official website. Visit the following link and locate the Go binary tarball file in the “All releases” section:

Install Go from Binary (.tar) on Ubuntu 24.04

You can directly download the file by clicking on the file link, such as go1.23.0.linux-amd64.tar.gz.

Step 2: Download the “Go” Binary (.tar):

The “wget” command can also be used to download the binary file from the source link:

Install Go from Binary (.tar) on Ubuntu 24.04

This command will download the Go tarball file and save it to your local folder.

Step 3: Extract the “Go” File to “/usr/local”

Execute this one-liner script to extract the downloaded tarball file to the “/usr/local” path:

Install Go from Binary (.tar) on Ubuntu 24.04

When the command runs it will extract the Go tarball file to the particular directory, such as “/usr/local”.

Step 4: Add “Go” to the PATH

Adding Go to the PATH variable makes the Go command available system-wide, so you can use “Go” commands from any directory. To do this task, execute the provided command:

Install Go from Binary (.tar) on Ubuntu 24.04

Now you can run Go from any directory.

Step 5: Reload “.profile” File

To reload your “.profile” file with the below command to apply the changes immediately:

Install Go from Binary (.tar) on Ubuntu 24.04

After running this command, you do not need to reboot your Ubuntu 24.04 machine.

Step 6: Verify “Go” Installation

Finally, confirm the Go installation using the below-mentioned command:

Install Go from Binary (.tar) on Ubuntu 24.04

This will return the Go version, such as “go1.23.0”, confirming that Go is installed on your Ubuntu 24.04 system.

How to Uninstall Go from Ubuntu 24.04?

These three methods can be utilized to remove or uninstall the Go programming language from Ubuntu 24.04.

Method 1: How to Uninstall Go from Ubuntu 24.04 using APT?

Utilize the “purge” option from the APT package manager to completely uninstall the Go package from your Ubuntu 24.04 system:

Uninstall Go from Ubuntu 24.04 using APT
Uninstall Go from Ubuntu 24.04 using APT

This command is useful if you want to remove all the configuration files associated with Go.

Method 2: How to Remove Go from Ubuntu 24.04 using Snap?

The Go package can be removed from your Ubuntu 24.04 system via the Snap command:

Method 2: How to Remove Go from Ubuntu 24.04 using Snap?

A confirmation message will be displayed on your terminal screen once the removal process is complete.

Method 3: How to Uninstall Go from Ubuntu 24.04 Manually?

Step 1: Remove Go Package

Run this command to remove the Go installation directory from your system:

How to Remove Go from Ubuntu 24.04 using Snap

This script removes the directory associated with Go.

Step 2: Remove Go PATH Variable

Access the “.profile” file from the terminal:

Method 2: How to Remove Go from Ubuntu 24.04 using Snap?

Locate the line containing the Go PATH Variable and remove it:

Method 2: How to Remove Go from Ubuntu 24.04 using Snap?

You can use Ctrl+K to remove the whole line.

Step 3: Apply the Changes

Execute the below command to reload the “.profile” file and update the changes:

Method 2: How to Remove Go from Ubuntu 24.04 using Snap?

Step 4: Verify Uninstallation of Go

After finishing the removal of Go, verify it by using this command:

Method 2: How to Remove Go from Ubuntu 24.04 using Snap?

If the command returns the output “No such file or directory”, the Go package has been successfully removed from your Ubuntu 24.04 system.

FAQs

Can I install Go on Ubuntu 24.04 using the binary file?

Yes, you can install Go on Ubuntu 24.04 utilizing the binary file. First, download the binary file from the Go website. Extract the file with “sudo tar -C /usr/local -xzf go1.23.0.linux-amd64.tar.gz”, and then add Go to the PATH variable.

What is the command to install Go on Ubuntu 24.04 via APT?

To install the Go package on Ubuntu 24.04 through APT, here is the command: “sudo apt install golang-go”.

Where can I download the Go binary file for Ubuntu 24.04?

You can download the Go binary file for Ubuntu 24.04 from the official Go website: “https://go.dev/”.

Conclusion

There are multiple ways to install Go on Ubuntu 24.04. You can use methods such as installing via APT with the command “sudo apt install golang-go”, installing via Snap with “sudo snap install go –classic”, or setting it up from a binary (.tar) file.

Scroll to Top