The Go language or Golang is one of the youngest yet popular, stable, high performing and production-ready computer programming language designed by Robert Griesemer, Rob Pike and Ken Thompson at Google back in 2007. Their main intention behind the Go programming language was to create an efficient yet simple and easy to use programming language. The first public release of the Go programming language was in 2009 and Version 1.0 was released in 2012. Since then until now there are millions of Go programmers, a bunch of fast-growing frameworks and supporting libraries around the world. In addition to that, big tech giants like Google, Facebook, AmericanExpress, PayPal, Cloudflare, Uber, Twitch and many other companies have put their trust in the Go language to build their mission-critical products. Furthermore, read (Go Case Studies)[https://go.dev/solutions/] to learn more about how companies use the Go language for their products to harness the capabilities of the Go language.
In this article, we are going to learn how to install and set up the Go programming language on Ubuntu. There are many methods that exist to install the Go language. But here we are focusing only on the most popular methods. The very first method that we are going to use is the easiest method which uses the built-in package manager of the Ubuntu Operating System. One major drawback of using the system package manager to install applications is you always do not get the latest versions. Especially, Debian based distributions like Ubuntu usually tend to get more stable and older versions rather than the latest versions. So in the second method, we are going to download and use the latest official Go binaries by manually downloading them from the official Go website. Major drawbacks of the second approach are, the installation process is not as easy as the first method and when there is an update, you will have to manually download and replace the old Go binary. However, even though we described both methods, you only need to follow one method to install the Go language. So before proceeding, decide whether you are going to use the package manager or manual download method.
Install Go Language With Package Manager
Installing the Go computer programming language with the system package manager is relatively easy and straightforward. Just open a terminal window and run the following commands. Make sure that you have root permissions to run these commands.
The following command will update the local package repository list.
sudo apt-get update
Install the Go language.
sudo apt-get install golang
That is all, now you have successfully installed the Go programming language and you can start writing Go applications.
Golang Web Download Installation
So you have decided to use the latest versions of Go language and a little bit comfortable playing with the terminal, good! Open your browser and go to https://go.dev. Click the “Download” button.
tar.gz archive file to your home directory.
Extract the downloaded
tar.gz file using the following command. It will extract the archive file to a directory called
go in the home directory. We are using the
x flag for extract,
v for verbose output,
z for gzip and
f for the archive file name.
tar -xvzf go1.17.5.linux-amd64.tar.gz
Now we need to make the
go command available anywhere in the terminal regardless of the directory we are in. Go to the Go bin directory we extracted in the previous step.
go binary to the
/usr/local/go/bin/ directory. Make sure to use a privileged account or otherwise, you will not be able to move files into this directory.
sudo mv go /usr/local/go/bin/
Run the following command to mention the path to the
go binary. The following command will open the
.bashrc file with the
nano text editor.
Add the following lines at the bottom of the
.bashrc file that we opened with the
nano text editor in the previous step. Once pasted, press
x and then
y to save the file. If you need, you can even use a graphical text editor something like
gedit for this step.
# Go path
Run the following command to make changes immediately available with the terminal window that we are using.
Run the following command, it should print the version of the Go language.
Run the following command to confirm whether it displays the correct path of the
In the first part of this article, briefly, we learned the history and the background of the Go language. After that, we learned how to install the Go language using the built-in package manager in Ubuntu which is recommended for most users who just want to quickly get started with Go application development. In the last part, we learned how to install the Go language by manually downloading and configuring the Go language which is usually recommended for users who need more control over the built-in package manager provided by Ubuntu. What do you think about this article? Did we miss something useful that you knew? Let’s discuss all of them in the comment section.