The go programming language has been in trend in recent years. This article will discuss different ways to install golang or go language in Linux ubuntu. We will also discuss how to check the go version after installation.
Check if Golang is Present in Linux
Before installing golang, let us first check if golang is already present in our machine. To check if Golang is already installed, we can check the golang version using the command go version
in the command line terminal as shown below.
In the above output, you can observe that Golang is not installed on our system. Therefore, let us install it on our Linux machine.
Install go in Linux Ubuntu using Apt
To install golang in ubuntu, you can use the command line terminal. You will also need the administrator password i.e. root password for this.
For go installation using apt, you can execute the following command.
sudo apt-get install golang-go
After execution of the above command, the go compiler will be installed on your system and you will get the following output screen.
Before running the above command, you can also execute the following commands to update all the dependencies and upgrade them.
sudo apt-get update
sudo apt-get upgrade
Install Golang in Linux Ubuntu using Snap
Instead of using Apt, you can also use the snap store to install golang in Ubuntu Linux. For this, you can execute the following command.
sudo snap install go
After executing the above command, you will get a warning message saying that the revision of snap go was published using classic confinement and thus may perform arbitrary system changes outside of the security sandbox that snaps are usually confined to, which may put your system at risk.
To ignore the above warning and install golang using snap on your ubuntu machine, you can execute the following command.
sudo snap install go --classic
After executing the above command in the command line, the golang compiler will be installed on your machine and you will get the following output.
Verify Golang Installation: Check Golang Version
To confirm that golang has been installed on your machine, you can check the golang version. To check the go version installed on your machine, you can execute the following command in the command line.
go version
After executing the above command, the golang version will be printed in the output as shown below.
Conclusion
In this article, we have discussed the installation of the golang compiler in Linux Ubuntu. We also discussed how to check the go version to confirm the installation of Golang.
To learn more about programming, you can read this article on command line arguments using sys.argv in Python. You might also like this article on python SimpleHTTPServer.
I hope you enjoyed reading this article. Stay tuned for more informative articles.
Happy Learning!