How to Install Go 1.12 on Ubuntu 18

This guide is also available as a video from Youtube.

Begin by running the following command to add the golang backports ppa:

sudo add-apt-repository ppa:longsleep/golang-backports

If you get an error such as “add-apt-repository command not found” then you need to run the following command to install add-apt-repository:

sudo apt-get install software-properties-common

Then run the following two commands to update your packages from the ppa and install Go version 1.12:

sudo apt-get update 
sudo apt-get install golang-1.12

Now we need to add the go binary to our path. I like to put his in my `.profile` by typing:

nano ~/.profile

Then scrolling to the bottom and adding the following line

PATH="$PATH:/usr/lib/go-1.12/bin"

Then use the source command to reread your profile.

source ~/.profile

Now type:

go version

And you should see that Go 1.12 is installed.

Author: Markus Tenghamn

I have been building websites and apps since I was 13. At 18 I was running my own web hosting company. I love writing, it is one of my favorite hobbies which lets me share things I find interesting with others. Don't forget to follow me on Twitter.

3 thoughts on “How to Install Go 1.12 on Ubuntu 18”

  1. # after apt install, maybe better use alternatives:
    # 1. check if your go installation (if any) is using alternatives:
    sudo update-alternatives –all –skip-auto
    #dpkg -S /usr/bin/go # check if you have any go package, like the default golang-go
    #sudo update-alternatives –install
    sudo update-alternatives –install /usr/bin/go go /usr/lib/go-1.12/bin/go 0
    sudo update-alternatives –install /usr/bin/go go /usr/lib/go-1.14/bin/go 3
    sudo update-alternatives –list go

    sudo -H gedit /etc/environment
    GOROOT=/usr/
    GOPATH=~/.go
    # and add to the end of path :$GOROOT/bin:$GOPATH/bin to the end of PATH var

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.