UbuntuUbuntu Based

How To Install GO on Ubuntu 24.04 LTS

Install GO on Ubuntu 24.04

In this tutorial, we will show you how to install GO on Ubuntu 24.04 LTS. GO, also known as Golang, is a powerful and efficient programming language developed by Google. It has gained immense popularity among developers due to its simplicity, performance, and built-in concurrency features. GO is widely used for building scalable and robust applications, making it an essential tool for modern software development.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the GO programming language on Ubuntu 24.04 (Noble Numbat). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.


  • A server running one of the following operating systems: Ubuntu and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
  • An Ubuntu 24.04 system with root access or a user with sudo privileges.

Install GO on Ubuntu 24.04 LTS Noble Numbat

Step 1. Updating the Package Repository.

Before installing any package, it’s a good practice to update the package lists to ensure you have access to the latest available versions. Open a terminal and run the following command:

sudo apt update

This command will fetch the latest package information from the Ubuntu repositories, allowing you to install the most recent version of Go and its dependencies. Updating the package repository is crucial to maintaining the security and stability of your system.

Step 2. Installing GO Programming Language on Ubuntu 24.04.

To install GO on your Ubuntu 24.04 system, you first need to download the appropriate version of GO from the official website. Visit the GO downloads page and select the latest stable version for Linux. At the time of writing, the latest version is GO 22.2.

You can download GO using the following command in your terminal:

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

Now that you have downloaded the GO archive, it’s time to install it on your Ubuntu 24.04 system. First, extract the downloaded archive to the /usr/local directory using the following command:

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

Next, you need to set up the necessary environment variables for GO. Open the .profile file in your home directory using a text editor:

nano ~/.profile

Add the following lines at the end of the file:

export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Save the changes and exit the text editor. The GOROOT variable specifies the location where GO is installed, while GOPATH sets the workspace directory for your GO projects. The PATH variable ensures that the system can find the GO executable files.

To apply the changes, either log out and log back in or run the following command:

source ~/.profile

Step 3: Configuring the Workspace.

GO follows a specific workspace structure to organize your projects and dependencies. It’s essential to set up your workspace correctly to avoid any issues later. Create a new directory for your GO workspace:

mkdir -p $HOME/go/{src,pkg,bin}

This command creates three subdirectories within the go directory: src for your GO source files, pkg for compiled package objects, and bin for compiled executable files.

Set the GOPATH environment variable to the workspace directory by running:

export GOPATH=$HOME/go

To verify that GO is installed correctly on your Ubuntu 24.04 system, run the following command:

go version

If the installation was successful, you should see the version number of GO printed in the terminal.

Step 4. Writing Your First GO Program.

Now that you have successfully installed GO on your Ubuntu 24.04 system, let’s write a simple “Hello, World!” program to test your setup. Create a new file named hello.go in your workspace’s src directory:

nano $HOME/go/src/hello.go

Add the following code to the file:

package main

import "fmt"

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

Save the file and exit the text editor. To compile and run the program, use the following commands:

cd $HOME/go/src
go build hello.go

If everything is set up correctly, you should see “Hello, World!” printed in the terminal.

Step 5. Managing GO Versions.

As you continue to work with GO, you may need to manage multiple versions of the language for different projects. There are several tools available to help you easily switch between GO versions, such as gvm (GO Version Manager) and goenv.

To install gvm, run the following command:

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)

Once installed, you can use gvm to install and manage different GO versions:

gvm install go1.22
gvm use go1.22

Step 7. Installing Common GO Tools and Libraries.

GO provides a rich ecosystem of tools and libraries that can enhance your development experience and productivity. Some essential tools include gofmt for code formatting, godoc for generating documentation, and golint for linting your code.

To install these tools, use the following commands:

go get golang.org/x/tools/cmd/gofmt
go get golang.org/x/tools/cmd/godoc
go get golang.org/x/lint/golint

Additionally, you can explore popular GO libraries and frameworks like Gin, Echo, and GORM, which can be installed using the go get command followed by the library’s import path.

Congratulations! You have successfully installed Go. Thanks for using this tutorial for installing the Go programming language on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the Golang website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button