Skip to content

Instantly share code, notes, and snippets.

@missinglink
Last active October 21, 2021 17:39
Show Gist options
  • Save missinglink/4212a81a7d9c125b68d9 to your computer and use it in GitHub Desktop.
Save missinglink/4212a81a7d9c125b68d9 to your computer and use it in GitHub Desktop.
Install go on ubuntu

note: always check for the latest versions, the version numbers shown here will fall out of date quickly.

Installing Go on Ubuntu:

Step 1. Grab yourself a binary release from here: https://golang.org/dl/

You'll want to use one from the Stable versions, you probably want one which is in bold, for Ubuntu it's xxx-linux-amd64.tar.gz

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

Step 2. Install

sudo tar -C /usr/local -xzf go1.4.linux-amd64.tar.gz;

Step 3. Decide where your packages will live

unless your name is also peter you might want to change that bit!

mkdir /home/peter/.go;

Step 4. Configure Environment

On Ubuntu you can edit ~/.bashrc to set your PATH, at the bottom add:

change the path below to match the one you created in step 3!

# The go binary, so we can actually run it
export PATH=$PATH:/usr/local/go/bin;

# This is where all your go packages live
GOPATH=/home/peter/.go;
export GOPATH;

# Add GOPATH/bin so compiled go libs appear on your PATH
export PATH=$PATH:$GOPATH/bin;

Step 5. Run that script

Every new terminal will run the above scripts when it starts; to apply it to the current terminal window we just:

source ~/.bashrc

Step 6. Test

$ go version
go version go1.4 linux/amd64

Full install instructions can be found here: https://golang.org/doc/install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment