I have Ubuntu 14.4.03. The default golang version which came with it was 1.2.1. I would like to update golang to 1.4 or higher.

After searching I found the way to do this would be to first delete current go installation and then re-install the new version.

I found the following go installation files in the following directory:


Which directory contains what? Which ones should I delete? What should be the location of new installation? It seems /usr/local is more normal. Then how come Ubuntu default is as above?

What would be the procedure to install a new version og golang?



11 Answers 11


ppa:evarlast/golang1.4 is not working for me. The manual way of installing Go is given below.

For more detailed installation instruction: Install the latest Golang on Linux

Step 1: Remove the existing golang

sudo apt-get purge golang*

Step 2: Download the latest version from the official site. Click Here

Step 3: Extract it in /usr/local using the following command. I am using Go 1.11.4 here. You may need to replace the filename with the actual filename based on the version you have downloaded.

tar -C /usr/local -xzf go1.11.4.linux-amd64.tar.gz

Step 4: Create .go directory in home. (It is easy to install the necessary packages without admin privilege)

mkdir ~/.go

Step 5: Set up the following environment variables


Check this link on how to set environment variables permanently.

Step 6: Update the go command

sudo update-alternatives --install "/usr/bin/go" "go" "/usr/local/go/bin/go" 0
sudo update-alternatives --set go /usr/local/go/bin/go

Step 7: Test the golang version

go version
  • 2
    I really liked this answer because it described nicely how Debian Alternatives System works! +1
    – fgbreel
    Sep 2, 2017 at 13:02
  • This did not work for me to upgrade from 1.8 to 1.9. Neither did the official guide here github.com/golang/go/wiki/Ubuntu
    – Karlom
    Jan 20, 2018 at 16:59
  • This is the right solution except that the tar command is not valid, which is fine to just provide your tar file full name. Thanks!
    – Montaro
    Oct 11, 2018 at 8:53
  • Legend. Thank you very much! Change the tar command line's file name though.
    – Mihailo
    Dec 18, 2018 at 20:14
  • 1
    working like a charm, cheers !
    – PKumar
    Oct 4, 2019 at 5:24

First remove your current golang installation with this command, you don't need to manually remove files installed by apt-get,

sudo apt-get purge golang

For an easy install of golang 1.4 you can use this PPA

sudo add-apt-repository ppa:evarlast/golang1.4
sudo apt-get update

Now you can use

sudo apt-get install golang

This will install version 1.4, here is a link to the PPA.

  • This is not working now as ppa is removed . Next answer is working Dec 6, 2016 at 6:06

I have found an alternative(/personal) repo with latest versions, which is still alive, then got the go-1.8 and linked it from the path in the OP's question. Here be bash it in:

sudo add-apt-repository ppa:gophers/archive
sudo apt-get update

sudo apt-get install golang-1.8

sudo ln /usr/lib/go-1.8/bin/go /usr/bin/go1.8

Now I can just say go1.8 instead of go and thus go with the latest&greatest.

The repo offers many other versions so you'd just change the version number to ex. 1.4 in the script/commands above.


For Golang 1.8 on Ubuntu 17.04 Zesty to 17.10 Artful:

# sudo apt update
# sudo apt install golang-1.8 golang-1.8-doc
# for bin in /usr/lib/go-1.8/bin/* ; do
    sudo update-alternatives --install /usr/bin/$(basename $bin) $(basename $bin) $bin 0
    sudo update-alternatives --set $(basename $bin) $bin

For Golang 1.9 on Ubuntu 17.10 Artful to 18.04 Bionic:

# sudo apt update
# sudo apt install golang-1.9 golang-1.9-doc
# for bin in /usr/lib/go-1.9/bin/* ; do
    sudo update-alternatives --install /usr/bin/$(basename $bin) $(basename $bin) $bin 0
    sudo update-alternatives --set $(basename $bin) $bin

For Golang 1.10 on Ubuntu 18.04 Bionic and 18.10 Cosmic:

# sudo apt update
# sudo apt install golang-1.10 golang-1.10-doc
# for bin in /usr/lib/go-1.10/bin/* ; do
    sudo update-alternatives --install /usr/bin/$(basename $bin) $(basename $bin) $bin 0
    sudo update-alternatives --set $(basename $bin) $bin

To install the latest version of Go programming language in all currently supported versions of Ubuntu open the terminal and type:

sudo snap install go --classic --channel stable 

You might need to install snapd support because this is not installed by default on server installations.

sudo apt install snapd && sudo reboot

This snap provides an assembler, compiler, linker, and compiled libraries for the Go programming language. There are other channels besides stable, but the stable channel is the latest version of Go programming language. The go snap package will be updated automatically when updates are available.


Easy install and update

Use Go Version Manager

# Add basic packages
sudo apt-get install curl git mercurial make binutils bison gcc build-essential

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

# Install which version you want to install
gvm install go1.9

# Use it as default version
gvm use go1.9 --default

You can also use the update-golang script:

update-golang is a script to easily fetch and install new Golang releases with minimum system intrusion

git clone https://github.com/udhos/update-golang
cd update-golang
sudo ./update-golang.sh

I use this script to automate Golang updates:


  • it has more than 1k stars which shows the pathetic stature of golang, a repo is needed to update and install it. May 11, 2021 at 19:10
  • 1
    Eh. To be fair, Python also typically needs a custom script, as well, on most systems, to install correctly. See: askubuntu.com/questions/1296790/… On Windows, python also needs to be aliased in PATH (at least, semi) manually, for it to work on the command line (without specifying path to python.exe every time).
    – vdoogs
    May 5 at 16:12

Remove existing golang

sudo apt-get purge golang*

Install snap if not yet installed

sudo apt update
sudo apt install snapd

Install via snap

sudo snap install go --classic

I use this instruction to install the latest version of IMG:

  1. Remove the existing Go version:

    sudo apt-get purge golang*
  2. Install the latest version of Go:

    sudo add-apt-repository ppa:longsleep/golang-backports
    sudo apt-get update
    sudo apt-get install golang-go
  3. Create the .profile file in the home path with this content:

    # ~/.profile: executed by the command interpreter for login shells.
    # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
    # exists.
    # see /usr/share/doc/bash/examples/startup-files for examples.
    # the files are located in the bash-doc package.
    # the default umask is set in /etc/profile; for setting the umask
    # for ssh logins, install and configure the libpam-umask package.
    #umask 022
    # if running bash
    if [ -n "$BASH_VERSION" ]; then
        # include .bashrc if it exists
        if [ -f "$HOME/.bashrc" ]; then
            . "$HOME/.bashrc"
    # set PATH so it includes user's private bin directories
  4. Set Go workspace to the environment variable:

  5. Apply the .profile configuration:

    source ~/.profile


$ go version
go version go1.11.1 linux/amd64

Ref: Go-GitHub-Installation


Learn latest version from: https://golang.org/dl/

sudo apt-get purge golang*  # in case there is old version of go is installed

tar_name="go1.15.8.linux-amd64.tar.gz"  # get latest version from https://golang.org/dl/
wget https://golang.org/dl/$tar_name
tar -xvf $tar_name
rm -f $tar_name
sudo rm -rf /usr/local/go
sudo mv go /usr/local

# Add following lines into `.bashrc` or `.zshrc`
mkdir -p $HOME/go
export GOPATH=$HOME/go
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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