Skip to content

Instantly share code, notes, and snippets.

@tsaarni
Last active November 8, 2017 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsaarni/231bc8e32b7e605d6bd500f270ca1209 to your computer and use it in GitHub Desktop.
Save tsaarni/231bc8e32b7e605d6bd500f270ca1209 to your computer and use it in GitHub Desktop.
Installing any version of go compiler on ubuntu

Prepare working environment for go compiler

Create "go path" directory (will store downloads and the source code that you yourself write)

mkdir ~/go

add following to your .bashrc or somewhere

if [ -d $HOME/go ]; then
   export GOPATH=${HOME}/go
   export PATH=${PATH}:${GOPATH}/bin
fi

Bootstrapping any version of go compiler on ubuntu

Begin by installing ubuntu version of golang

sudo apt install golang

Then donwload, compile and install "godeb". Godeb transforms upstream tarballs for the Go language in deb packages and installs them.

go get gopkg.in/niemeyer/godeb.v1/cmd/godeb

To use godeb run

godeb list            # list all available versions
godeb install         # build latest
godeb install 1.8.3   # build specific version

Run following to build latest golang compiler. This will take a while...

godeb install

After build finishes the package that godeb built will be in current dir

ls go_*.deb

Uninstall the ubuntu version of golang before installing the new version (they would conflict)

sudo apt remove golang
sudo apt auto-remove

Then install

sudo dpkg -i go_*.deb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment