Golang Installation and Setup On Ubuntu and POP!OS Linux

In this blog post, I will show you how to install Go on Ubuntu or POP!OS Linux.

Installing GO

Go binary distributions are available for all major operating system but in this blog post I will focus on Ubuntu Linux and its derivatives.

Downloading GO

Download the Linux distribution from Go’s official download page

Extract and Copy Files

Next, extract  and copy the files to /usr/local

Add GO TO PATH

Next, add /usr/local/go/bin to your PATH environment variable. You can do this by adding the following line to your ~/.profile file:

Creating and Setting GOPATH

The GOPATH is where you will save your projects. This folder will have 3 sub-folders:

  • src — This folder is where you will store your Go projects.
  • pkg — All shared packages are stored in this folder.
  • bin — This folder is where your compiled Go programs will be placed.

Create the GOPATH Folder

Next, create a folder for your GOPATH somewhere on your system (you can pick any name) and inside of this create the 3 folders above.

Add GOPATH TO PATH

Next, add the GOPATH folder PATH environment variable. You can do this by adding the following line to your ~/.profile file:

Testing Go Installation

In order to test your installation of GO it is best if you log out and log back into Linux. To test the installation you will run few commands that will show the version of Go and some Go environment variables.

 Go Version

To show the Go Version run this command:

Go Environment Variables

To show the Go environment variables run this command:

If these commands run successfully, you have install Go your our computer correctly.

Conclusion

In this blog post, you learned how to install Go and how to test your installation

Harrison Brock