Install Golang On Ubuntu

7 Easy Steps to Install Go (Golang) on Ubuntu

Written by: Ryan Frankel

Ryan Frankel

Ryan began developing websites in the late '90s and has personally tested just about every web host and cloud platform worth trying on the market today. With a masters degree in electrical and computer engineering from the University of Florida, he leverages his extensive knowledge of hardware, software, and their engineering relationship to inform HostingAdvice readers of the technical implications of their hosting choices. Ryan's subject matter expertise includes, but is not limited to, WordPress, cloud infrastructure management, product UI/UX design, and popular web development languages such as JavaScript and PHP.

See full bio »

Edited by: Lillian Castro

Lillian Castro

Lillian brings more than 30 years of editing and journalism experience to our team. She has written and edited for major news organizations, including The Atlanta Journal-Constitution and the New York Times, and she previously served as an adjunct instructor at the University of Florida. Today, she edits HostingAdvice content for clarity, accuracy, and reader engagement.

See full bio »

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

bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)

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

[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"

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

$ gvm version  Go Version Manager v1.0.22 installed at /home/myuser/.gvm

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.

$ gvm listall  ...  go1.2rc5  go1.3  go1.3.1  go1.3.2  go1.3.3  go1.3beta1  go1.3beta2  go1.3rc1  go1.3rc2  go1.4  go1.4beta1  go1.4rc1  go1.4rc2

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

Let’s install Go 1.4.

$ gvm install go1.4  Downloading Go source...  Installing go1.4...  * Compiling...  

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.

$ gvm use go1.4  Now using version go1.4

Sweet. Everything is going great so far.

7. Verify Go Is Installed Correctly

$ go version  go version go1.4 linux/amd64

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.

gvm install go1.4   gvm use go1.4   export GOROOT_BOOTSTRAP=$GOROOT   gvm install go1.5  

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

Advertiser Disclosure

HostingAdvice.com is a free online resource that offers valuable content and comparison services to users. To keep this resource 100% free, we receive compensation from many of the offers listed on the site. Along with key review factors, this compensation may impact how and where products appear across the site (including, for example, the order in which they appear). HostingAdvice.com does not include the entire universe of available offers. Editorial opinions expressed on the site are strictly our own and are not provided, endorsed, or approved by advertisers.

Our Editorial Review Policy

Our site is committed to publishing independent, accurate content guided by strict editorial guidelines. Before articles and reviews are published on our site, they undergo a thorough review process performed by a team of independent editors and subject-matter experts to ensure the content’s accuracy, timeliness, and impartiality. Our editorial team is separate and independent of our site’s advertisers, and the opinions they express on our site are their own. To read more about our team members and their editorial backgrounds, please visit our site’s About page.

ABOUT THE AUTHOR

Ryan Frankel has been a professional in the tech industry for more than 20 years and has been developing websites for more than 25. With a master's degree in electrical and computer engineering from the University of Florida, 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.

« BACK TO: HOW-TO
Follow the Experts
We Know Hosting

$

4

8

,

2

8

3

spent annually on web hosting!

Hosting How-To Guides