Golang (Go) is a programming language provided by Google to help developers create scalable and secure systems. Its simplicity makes any developer want to learn the language and use it quickly.
While Go is a go-to programming language for many developers, you must first install it on Ubuntu 24.04 before you begin using it for your development. We’ve covered three installation methods that anyone can use. Read on!
The Go programming language has numerous applications, and as a Ubuntu user, you have three methods for installing Go. You can source it from the snap store or install it from the Ubuntu repository using APT. Still, you can download the Go tarball, extract it, and add its path to make it accessible on your system. All these methods are discussed below.
Method 1: Install Go on Ubuntu 24.04 Via APT
The first step in this method is to update the Ubuntu 24.04 repository. The Go version installed with this method is stable but not always the latest available version.
Let’s first update the system.
Next, use APT to install the Go package.
Once the installation process is completed, view the installed Golang version.
Method 2: Install Go Via Snap
Even on Ubuntu 24.04 (Noble Numbat), you can access the Snap Store and install Snap packages. Go is available as a Snap package, and installing it via this approach will install even its dependencies.
Here, you only need to execute the below command.
Similarly, we can check the installed Go version.
Notice how the two methods install the same Go version, which is the latest version when writing this post.
Method 3: Install Go Via Its Official Repository
The official way of installing Go on any Linux distribution is by sourcing its binary package. However, this is a long method as more steps are involved, but if you want the latest version or a specific Go version, this method is the best.
The first step is to update the system.
Next, visit the Go download page and find the version you want to install. Ensure you select the appropriate architecture for compatibility. We’ve chosen version 1.22.2 for this example.
Once you’ve selected it, download the tarball using any utility. We’ve used wget for our example.
Allow the download to complete. The next step involves extracting the archive file. We’ve extracted it to the /usr/local/ directory using the tar command below.
We’ve also run the ls command to confirm that the file was successfully unzipped and the new uncompressed Go folder containing all the required files exist.
So far, we have the Go folder on our system, but we must add its binary to the path environment variable before we start using Go system-wide. Using a text editor, we will edit our bashrc to add the Go binary.
Let’s open the file using the nano text editor.
Next, paste the below line inside the file.
Save the changes and exit the file. Also, source the file for the changes to apply.
Lastly, check the installed version.
Now that we’ve installed the Go programming language, we can use it for our development. Let’s create a simple ‘hello’ program to test that Go works correctly. Save it with a .go extension.
Save the file and run it using the below syntax.
That’s it! The output confirms that Go is successfully installed on Ubuntu 24.04.
Go is a recent programming language developed by Google. Ubuntu supports Go and there are three ways you can install it. You can install it via APT or snap. Moreover, you can install it by downloading its official repository and adding its binary to your environment variable. Have fun using Go on Ubuntu 24.04.
One of the most critical gaps in traditional Large Language Models (LLMs) is that they…
Canonical is continuously hiring new talent. Being a remote- first company, Canonical’s new joiners receive…
What is patching automation? With increasing numbers of vulnerabilities, there is a growing risk of…
Wouldn’t it be wonderful to wake up one day with a desire to explore AI…
Ubuntu and Ubuntu Pro supports Microsoft’s Azure Cobalt 100 Virtual Machines (VMs), powered by their…
Welcome to the Ubuntu Weekly Newsletter, Issue 870 for the week of December 8 –…