X
Collapse
-
How to Install Go on Ubuntu 24.04
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!
Three Methods of Installing Go on Ubuntu 24.04
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.
$ sudo apt update
Next, use APT to install the Go package.
$ sudo apt install golang-go
Once the installation process is completed, view the installed Golang version.
$ go 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.
$ sudo snap install go --classic
Similarly, we can check the installed Go version.
$ 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.
$ sudo apt update
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.
$ wget https://go.dev/dl/go1.22.2.linux-amd64.tar.gz
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.
$ sudo tar -C /usr/local -xzf go1.20.1.linux-amd64.tar.gz
$ ls /usr/local/go
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.
$ nano ~/.bashrc
Next, paste the below line inside the file.
export PATH=$PATH:/usr/local/go/bin
Save the changes and exit the file. Also, source the file for the changes to apply.
$ source ~/.bashrc
Lastly, check the installed version.
$ go version
Test the Go Language
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.
$ go run program_name
That’s it! The output confirms that Go is successfully installed on Ubuntu 24.04.
Conclusion
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.
More...Tags: None
Posting comments is disabled.
Categories
Collapse
Article Tags
Collapse
There are no tags yet.
Latest Articles
Collapse
-
by KasimbaI don’t like my prompt, i want to change it. it has my username and host, but the formatting is not what i want. This blog will get you started quickly on doing exactly that.
This is my current prompt below:
To change the prompt you will update .bashrc and set the PS1 environment variable to a new value.
Here is a cheatsheet of the prompt options:
You can use these placeholders for customization:
\u – Username
...-
Channel: Articles
Today, 01:15 AM -
-
by KasimbaIn this post I will show you how to install the ZSH shell on Rocky Linux. ZSH is an alternate shell that some people prefer instead of BASH shell. Some people say ZSH has better auto-completion, theme support, and plugin system. If you want to give ZSH a try its quite easy to install and give it a try. This post is focused on the Rocky Linux user and how to install ZSH and get started with its usage.
Before installing anything new, it’s good practice to update your system packages:...-
Channel: Articles
12-25-2024, 02:01 AM -
-
by Kasimba
by George Whittaker
Introduction
In the world of operating systems, Windows has long held the lion’s share of the market. Its user-friendly interface and wide compatibility have made it the default choice for many. However, in recent years, Linux has steadily gained traction, challenging the status quo with its unique offerings. What was once considered the domain of tech enthusiasts and developers is now...-
Channel: Articles
12-21-2024, 06:52 AM -
-
by KasimbaOverview of NGINX and Apache
NGINX and Apache are leading web server solutions utilized for hosting websites and web applications. Apache, developed by the Apache Software Foundation, offers robust configuration options and extensibility. NGINX, created by Igor Sysoev, is known for its efficiency in handling numerous concurrent connections with low resource utilization. Both servers function not only as HTTP servers but also as reverse proxies, load balancers, and more.
What is
...-
Channel: Articles
12-21-2024, 03:54 AM -
-
by KasimbaHi everyone, I hope you are enjoying the BETA so far! This release introduces new features, tools, and artwork, so we anticipate a good number of bug reports. Every single fix helps us refine and improve the final release. Your feedback during the BETA phase is extremely important to us. Linux Mint 22.1 is our […]
More...-
Channel: Articles
12-16-2024, 11:50 AM -
-
by Kasimba
by George Whittaker
Introduction
Remote access is a cornerstone of modern IT infrastructure, enabling administrators and users to manage systems, applications, and data from virtually anywhere. However, with great power comes great responsibility—ensuring that remote access remains secure is paramount. This is where OpenSSH steps in, providing robust, encrypted communication for secure remote management....-
Channel: Articles
12-13-2024, 10:31 PM -