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.

Ryan Frankel

Questions or Comments? Ask Ryan!

Ask a question and Ryan will respond to you. We strive to provide the best advice on the net and we are here to help you in any way we can.

  • Jason Yost

    Thanks for the article, very helpful. Tip for you as well, the quickest way to reload .bashrc or any dotfile at all even gvm is to simply type source ~/.bashrc or in this case source ~/.gvm/scripts/gvm

    • frankel0

      Absolutely Jason. Thanks for the tip.

      In fact, you can use a ‘.’ as an alias for ‘source’. So you can type:
      . ~/.gvm/scripts/gvm
      as well as your example.

      We decided it was clearest to use the logout/login paradigm since most people learn that first.

  • Julian Doerner

    thank you, i wish i had read this 3 hours before !

    • frankel0

      No problem Julian. I’m glad it helped.

  • Thank you so much!!! I wish that I had found this a week ago!

    • frankel0

      I’m sorry you didn’t =(. GVM doesn’t get enough attention and it is an incredibly useful tool.

  • Nick G.

    Thank you, I was able to install it on my debian server with no problem at all!

    • frankel0

      Great! It’s always nice to know we haven’t totally blown it =).

      • Nick G.

        Just letting you know, I had 2 new servers and almost went crazy trying to install Go lang. I found this guide again and it work like a charm. Gvm is a very useful tool!

  • Kent Johnson

    Thank you for the article mr Frankel, it worked for me on Ubuntu 14.04 after I did an apt-get update and and apt-get install bison gcc

    • frankel0

      Fantastic. I’m glad everything worked out well for you!

  • Palmer 

    Very helpful. Thanks for sharing!

    • frankel0

      No problem Palmer. Thanks for the feedback.

  • Thanks!

    • frankel0

      I hope everything got installed and worked well.

  • keith R


    Nice Article.

    But i am facing an error

    I am trying to install go on Ubuntu 14.04, When i try to run this command sudo gvm install go1.4.2. This Error Comes “sudo: gvm: command not found”.

    Is there anything i have to install. Please advise

    • SB

      Don’t use sudo

      Just give “gvm install go1.4”

      • keith R


        Thanks for the reply.

        But when i try to use the command gvm install go1.4.2, I receive the below error

        /home/keith/.gvm/scripts/install: line 62: /home/keith/.gvm/logs/go-download.log: Permission denied

        ERROR: Couldn’t download Go source. Check the logs /home/keith/.gvm/logs/go-download.log

        • SB

          Even I had got a similar issue when I tried on another machine with ubuntu 12.04. Doing some research, I found that this was an issue with git. Update your git to the latest version.

          • cakka

            My git is latest version, but I got this error message too. Any ideas ?

    • frankel0

      Since gvm lives in your users directory “~/.gvm/” you have to use it without the sudo. This means that each users could/will-have-to have their own gvm installed.

      • keith R

        Hi frankel0,

        Thanks for the reply.
        But when i try to use the command gvm install go1.4.2, I receive the below error

        /home/keith/.gvm/scripts/install: line 62: /home/keith/.gvm/logs/go-download.log: Permission denied

        ERROR: Couldn’t download Go source. Check the logs /home/keith/.gvm/logs/go-download.log

  • Josh Taylor

    If you want to always use one version of go, use the –default flag with ‘use’. Otherwise you need to type in the command every new terminal.

    gvm use go1.4.2 –default

    • swapnil

      thanks 🙂

    • Cristian Hoyos

      thanks (y)

  • Ben Griffin

    How we get GVM to work with Go 1.5

    • frankel0

      Ben, we updated the article to include how to get Go 1.5 working. This should be fixed in the most recent updates of gvm.

  • SB

    Error with installing 1.5 and Solution:

    “gvm install go1.5” might give an error.

    You can find the solution here:

    Also update your git version
    ref: http://stackoverflow.com/questions/19109542/installing-latest-version-of-git-in-ubuntu

    • frankel0

      Thanks SB! We updated the article accordingly.

  • Lorenz Leitner

    Thank you very much!

    • frankel0

      Glad it helped.

  • Christophe Meessen

    Didn’t work for me. When I type gvm install go1.4 I get an error saying it failed using the installed version.

    ##### Building Go bootstrap tool.
    ERROR: Cannot find /home//go1.4/bin/go.
    Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.

    I wan’t to install Go 1.4. Obviously I don’t have a working Go tree >= Go 1.4. Otherwise I wouldn’t want to install Go 1.4.

    • Christophe Meessen

      I now installed go1.5.1 by downloading the tar file from https://golang.org/dl/. I installed it in /usr/local. I also removed the go installed by apt-get. Now when I type go version I get go version go1.5.1 linux/amd64, which is what I want. But gvm list still shows system and doesn’t see the version 1.5.1. So how is this all supposed to work ? I’m not convinced yet that gvm is a progress.

      Apparently the gvm script erase the GOROOT and GOPATH environment variables. How are we supposed to define the GOPATH ? I don’t want to install go stuff in the root of my home directory.

      EDIT: finally fixed it. After removing golang previously installed by apt-get, I erased .gvm and restarted the script. It found my go1.5.1 installed by untarring in /usr/local/go. It is named system in gvm list. After that I had to export GOROOT_BOOTSTRAP=/usr/local/go and could then gvm install go1.5.1. It worked. It now shows go1.5.1 next to system when performing a gvm list. With a ‘gvm use go1.5.1’ it uses the installed go.

  • I got this error when I run go get
    golang package bytes: unrecognized import path "bytes"
    I was using golang versi 1.5

  • SmartAss

    Or just:

    sudo apt-get install golang

  • HannesZ

    I get to this on step 2.

    2. Open Your ~/.bashrc and Source the GVM Directory
    1 [[ -s “$HOME/.gvm/scripts/gvm” ]] && source “$HOME/.gvm/scripts/gvm”

    should I copy and past that to the Ubuntu terminal ? [[ -s “$HOME/.gvm/scripts/gvm” ]] && source “$HOME/.gvm/scripts/gvm”

    uI am on Ubuntu 16.04

  • Rusty J

    Excellent Article!

    I had issues compiling Go, so I ended up using the -B option to gvm:
    gvm install go1.4 -B
    gvm install go1.9.2 -B
    gvm use 1.9.2 –default

    So far it’s working like a charm!

  • Krishnan Sriram

    It is very easy in ubuntu. You can do “sudo apt install -y golang-go”