Installing Golang 1.12 on Ubuntu 18.04


Author:
Published: 2019-07-09
Themes: #Golang #Ubuntu #administration
Words: 213


0/ Why doing that?


Golang is self-contained, it has no external dependencies. So upgrading a full Ubuntu distribution seems extreme, when the need is just being able to compile with "go 1.12" when you have "go 1.10" already installed on your system.


1/ Get the official *.deb files on launchpad.net


Go to https://launchpad.net/ubuntu/+source/golang-1.12 and search for the desired version. At the time of writing, the last stable is "1.12-1ubuntu1". Then locate the desired build (amd64, arm64, etc...) and download all the *.deb built files and put them in a new directory. In my case it's those :


2/ Install the packages


Then open a console and "cd" the directory then execute the command: "sudo dpkg -i *.deb". If external dependencies were needed, a "sudo apt install -f" would fix them.


3/ Link to the new version


"which go" will tell you what program is called when you type "go" in a console. In my case it's "/usr/bin/go".

If it's a link then "ll /usr/bin/go" will tell you where the link resolves, in my case it's "/usr/bin/go -> ../lib/go-1.10/bin/go*". Now to complete the upgrade, you only need to overwrite those 3 links:

  • "sudo ln -sf ../lib/go-1.12/bin/go /usr/bin/go"
  • "sudo ln -sf ../lib/go-1.12/bin/gofmt /usr/bin/gofmt"
  • "sudo rm /usr/lib/go && sudo ln -s go-1.12 /usr/lib/go"