7 Easy Steps to Install Go (Golang) on Ubuntu

Installing Go (Golang) can be tricky on Ubuntu. The repositories for versions 12.04 and 14.04 are dated and install an older version of Go.

Luckily, there is a tool called the Go Version Manager (gvm) to help install, maintain, and even switch Go versions. I know it can be a little scary not using apt-get or aptitude, but in this case, it is worth it.

The installation process simply involves a clone of a GitHub repo and a single line in your .bashrc.

1. Clone the Repo and Add to User Directory

This command uses cURL to grab the GitHub repo and install it within your user directory. The file that this repo is placed in is ~/.gvm.

2. Open Your ~/.bashrc and Source the GVM Directory

All we are doing here is linking the gvm binary to our environmental variables. This allows you to run GVM from any path on your command line.

3. Logout and Login with Your User

The easiest way to make the changes in your .bashrc take effect is to just log out and log back into your shell.

4. Check to Make Sure that GVM is Installed

This command will tell you which version of GVM is installed. If it reports a version back, then you have successfully installed GVM. Well done!

5.  Install Go (Golang)

First let’s check the versions of Go that are available.

As you can see, GVM includes the beta versions of software and release candidates (rc).

Let’s install Go 1.4.

6. Tell GVM Which Version of Go to Use

Now that we have Go installed on our system, let’s let GVM know we wish to use that version.

Sweet. Everything is going great so far.

7. Verify Go Is Installed Correctly

We are done! GVM makes this process simple, and upgrading, changing versions, and uninstalling Go is now simple as well.

Update: Installing Go 1.5 Might Take an Additional Step

Go has changed how they compile their source and it has caused some issues with gvm.  This is reported as fixed but I figured we should mention it just in case.  Basically, just install go1.4 before you install go1.5.

Have fun, and as usual, feel free to ask any questions below.

ABOUT THE AUTHOR
Ryan Frankel

Ryan Frankel has been a professional in the tech industry for more than 10 years and has been developing websites for more than 15. With his background in integrated circuit design and digital signal processing, he has a fundamental understanding of hardware systems and the software that runs them. Ryan now sits as the CTO of Digital Brands Inc. and manages all of the server infrastructure of their websites, as well as their development team. In addition, Ryan has a passion for guitars, good coffee, and puppies.