Running sudo apt-get install golang-stable, I get Go version go1.0.3. Is there any way to install go1.1.1?

share|improve this question
1  
In the end I had to install from source. Not all tests passed but it seems to be working ok. – Sofia Jul 5 '13 at 12:50
1  
"Not all tests passed but it seems to be working ok." @sofia what version of Ubuntu are you using? I would not expect test failures unless you were running a very old version of Ubuntu or you accidentally installed "tip" vs. "stable". – voidlogic Jul 9 '13 at 2:41
    
I'm using ubuntu precise. But installing the latest version from the repo duh/golang didn't report any problem, so not sure what the problem was. – Sofia Jul 10 '13 at 9:22
    
I am also using precise. Did you run "hg update tip" or "hg update release". If you don't recall look back in your bash history file. Using tip might explain the test failures. – voidlogic Jul 10 '13 at 13:49
1  
You can try this blog railskey.wordpress.com/2014/05/31/install-gogolang-on-ubuntu – Pravin Mishra May 31 '14 at 5:44

11 Answers 11

up vote 103 down vote accepted

I found a repo that has the latest versions: https://launchpad.net/~duh/+archive/golang/+packages. So basically do:

sudo apt-get install python-software-properties  # 12.04
sudo add-apt-repository ppa:duh/golang
sudo apt-get update
sudo apt-get install golang

To confirm:

go version

which outputs in my case (Ubuntu precise)

go version go1.1.1 linux/amd64

From there just export the settings you're gonna need to bash_rc or equivalent:

export GOROOT=/usr/lib/go
export GOBIN=/usr/bin/go
share|improve this answer
35  
So as of 2014 July, this no longer has the latest version of Go. Current version is 1.3. After trying this on Ubuntu 12.04, I ended up with version 1.1.1. – 425nesp Jul 22 '14 at 23:29
4  
Please update this. As of Sep 2014, I also end up with "go1.1.2" – Riccardo Oct 1 '14 at 19:21
2  
As of 2014-10-24, I got 1.2.1 linux/amd64. – nairware Oct 25 '14 at 2:25
5  
Checking in on March 29th, 2015. That ppa responds with a 404. – btleffler Mar 29 '15 at 13:49
7  
I used ppa:evarlast/golang1.4 – Natim May 21 '15 at 15:39

I like to use GVM for managing my Go versions in my Ubuntu box. Pretty simple to use, and if you're familiar with RVM, it's a nobrainer. It allows you to have multiple versions of Go installed in your system and switch between whichever version you want at any point in time.

Install GVM with:

sudo apt-get install bison mercurial
bash < <(curl -LSs 'https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer')
. "$HOME/.gvm/scripts/gvm"

and then it's as easy as doing this:

gvm install go1.1.1
gvm use go1.1.1 --default

The default flag at the end of the second command will set go1.1.1 to be your default Go version whenever you start a new terminal session.

share|improve this answer
1  
I like RVM and always enjoy a good tool in my kit. Glad to see as I get into Go that there's a tool like GVM :) – Brenden Oct 12 '13 at 3:49
1  
gvm has a lot of requirements... – Ari Mar 26 '14 at 14:56
2  
gvm is same name as for grails gvm – jcalloway Sep 23 '14 at 22:54
2  
I just tried using GVM under the fish shell, and a warning to those who don't use bash: GVM will be a pain to get up and running properly. A lot of its scripts don't have a shebang line for example. – Dennis Feb 13 '15 at 1:47
1  
This should be marked as the answer – Calin Sep 21 '15 at 6:59

I used following commands from GoLang official repository, it installed GoLang version 1.6 on my Ubuntu 14.04

sudo add-apt-repository ppa:ubuntu-lxc/lxd-stable
sudo apt-get update
sudo apt-get install golang

Reference official GoLang Repo https://github.com/golang/go/wiki/Ubuntu it seems this ppa will always be updated in future.

share|improve this answer
    
But the question was about Ubuntu Precise (12.04) and not 14.04... – Anton Protopopov Jan 25 '17 at 6:26

[October 2015] Answer because the current accepted answersudo apt-get install golang isn't uptodate and if you don't want to install GVM follow these steps.

Step by step installation:

  1. Download the latest version here (OS: Linux).
  2. Open your terminal and go to your Downloads directory
  3. sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
  4. Add go to your path export PATH=$PATH:/usr/local/go/bin
  5. go version to check the current version installed
  6. Start programming.

Possible errors + fixes: (to be updated)

If you get a go version xgcc (Ubuntu 4.9.1-0ubuntu1) 4.9.1 linux/amd64 then you did something wrong, so check out this post: Go is printing xgcc version but not go installed version

share|improve this answer
    
this should be the accepted answer – Kenichi Shibata Apr 13 '17 at 9:39

i installed from source. there is a step-by-step tutorial here: http://golang.org/doc/install/source

share|improve this answer
2  
yup. followed that and it worked. – Sofia Jul 5 '13 at 13:07
2  
yes. Installing Go from source is the best way to "Go". It is very easy to update that way as well. – voidlogic Jul 9 '13 at 2:34
1  
I followed the instructions from here and it worked for me really nice golang.org/doc/install#tarball – Bogdan Mar 15 '14 at 3:43
1  
Thank you so much. Still working on my Ubuntu 14.04 while the PPAs don't. :-) – Ionică Bizău May 2 '14 at 15:43
1  
This is annoying now that you have to bootstrap 1.5+ with a 1.4+ build. – jocull Jan 2 '16 at 17:17

Here is the most straight forward and simple method I found to install go on Ubuntu 14.04 without any ppa or any other tool.

As of now, The version of GO is 1.7

Get the Go 1.7.tar.gz using wget

wget https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz

Extract it and copy it to /usr/local/

sudo tar -C /usr/local -xvf go1.7.linux-amd64.tar.gz

You have now successfully installed GO. Now You have to set Environment Variables so you can use the go command from anywhere.

To achieve this we need to add a line to .bashrc So,

sudo nano ~/.bashrc

and add the following line to the end of file.

export PATH="/usr/local/go/bin:$PATH"

Now, All the commands in go/bin will work.

Check if the install was successful by doing

go version

For offline Documentation you can do

godoc -http=:6060

Offline documentation will be available at http://localhost:6060

NOTE:

Some people here are suggesting to change the PATH variable.

It is not a good choice.

  1. Changing that to /usr/local/go/bin is temporary and it'll reset once you close terminal.

  2. go command will only work in terminal in which you changed the value of PATH.

  3. You'll not be able to use any other command like ls, nano or just about everything because everything else is in /usr/bin or in other locations. All those things will stop working and it'll start giving you error.

However, this is permanent and does not disturbs anything else.

share|improve this answer
    
you need to define env var GOPATH=/some/dir then define PATH=${GOPATH}/bin:${PATH} for your own project code – Scott Stensland Aug 21 '16 at 15:22
    
Yes, I use VSCode so to add GOPATH I just need to edit gopath in user settings json. Thanks for the input. – Ishan Jain Aug 22 '16 at 19:48
    
There's a small typo in the tar command: am64 instead of amd64 – Adrian Lungu Sep 15 '16 at 6:21
1  
@AdrianLungu Fixed it. – Ishan Jain Sep 16 '16 at 15:16
1  
sudo nano ~./bashrc -> sudo nano ~/.bashrc .. also should be vim :p – GameKyuubi Nov 6 '16 at 20:19

If someone is looking for installing Go 1.8 the follow this:

sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt-get update
sudo apt-get install golang-go

And then install go

sudo apt-get install golang-1.8-go
share|improve this answer
    
Works flawless for me. Thanks! – Gwyneth Llewelyn Apr 21 '17 at 22:45
1  
No need to install golang-1.8-go, it's already installed when installing golang-go. Actually as of end April 2017, go 1.8.1 is installed, the latest version. github.com/golang/go/wiki/Ubuntu – firepol Apr 26 '17 at 11:10
    
I guess you also need to set up GOROOT, GOPATH – Nam G VU Aug 8 '17 at 3:25
    
Reference for GOROOT and GOPATH setting right in other answers 1) stackoverflow.com/a/34384978/248616 2) stackoverflow.com/questions/17480044/… More official reference stackoverflow.com/a/10847122/248616 – Nam G VU Aug 8 '17 at 3:43
    
For each of our Go project, set GOPATH=/some/dir, PATH=${GOPATH}/bin:${PATH} – Nam G VU Aug 8 '17 at 3:46
  1. Download say, go1.6beta1.linux-amd64.tar.gz from https://golang.org/dl/ into /tmp

wget https://storage.googleapis.com/golang/go1.6beta1.linux-amd64.tar.gz -o /tmp/go1.6beta1.linux-amd64.tar.gz

  1. un-tar into /usr/local/bin

sudo tar -zxvf go1.6beta1.linux-amd64.tar.gz -C /usr/local/bin/

  1. Set GOROOT, GOPATH, [on ubuntu add following to ~/.bashrc]

mkdir ~/go export GOPATH=~/go export PATH=$PATH:$GOPATH/bin export GOROOT=/usr/local/bin/go export PATH=$PATH:$GOROOT/bin

  1. Verify

go version should show be

go version go1.6beta1 linux/amd64

go env should show be

GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/vats/go" GORACE="" GOROOT="/usr/local/bin/go" GOTOOLDIR="/usr/local/bin/go/pkg/tool/linux_amd64" GO15VENDOREXPERIMENT="1" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0" CXX="g++" CGO_ENABLED="1"

share|improve this answer
    
Hi, thank you for answer, I am following all the steps but whenever I call "go version" instead of 1.7 it bring 1.4.2 . Is there any other actions that should be done ? – Anahit Serobyan Nov 18 '16 at 7:38

For the current release of Go:

The Go Programming Language

Getting Started

Download the Go distribution

Downloads

Click the link above to visit the Go project's downloads page and select the binary distribution that matches your operating system and processor architecture.

Official binary distributions are available for the FreeBSD, Linux, Mac OS X (Snow Leopard, Lion, and Mountain Lion), NetBSD, and Windows operating systems and the 32-bit (386) and 64-bit (amd64) x86 processor architectures.

If a binary distribution is not available for your combination of operating system and architecture you may want to try installing from source or installing gccgo instead of gc.

Installing Go from source

share|improve this answer
    
Installing from source is actually really fast. It compiles fast and the tests are optional if you choose to skip them. – Jeremy Wall Jul 5 '13 at 6:02

Or maybe you could use this script to install Go and LiteIDE?

share|improve this answer
  1. If you have ubuntu-mate, you can install latest go by:

    umake go

  2. I have a script to download and install the last go from official website

     # Change these varialbe to where ever you feel comfortable
     DOWNLOAD_DIR=${HOME}/Downloads/GoLang
     INSTALL_DIR=${HOME}/App
     function install {
        mkdir -p ${DOWNLOAD_DIR}
        cd ${DOWNLOAD_DIR}
    
        echo "Fetching latest Go version..."
        typeset VER=`curl -s https://golang.org/dl/ | grep -m 1 -o 'go\([0-9]\)\+\(\.[0-9]\)\+'`
        if uname -m | grep 64 > /dev/null; then
            typeset ARCH=amd64
        else
            typeset ARCH=386
        fi
        typeset FILE=$VER.linux-$ARCH
    
        if [[ ! -e ${FILE}.tar.gz ]]; then
             echo "Downloading '$FILE' ..."
             wget https://storage.googleapis.com/golang/${FILE}.tar.gz
        fi
    
        echo "Installing ${FILE} ..."
        tar zxfC ${FILE}.tar.gz ${INSTALL_DIR}
        echo "Go is installed"
    }
    
    install
    

Setup your GOROOT, GOPATH and PATH:

export GOROOT=${INSTALL_DIR}/go
export GOPATH=<your go path>
export PATH=${PATH}:${GOROOT}/bin:${GOPATH}/bin
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.