The go version provided with apt on ubuntu is usually “outdated”.
The recommended way to install the most recent version of go is described here:
https://golang.org/dl/
To get back on your track, here are the steps to follow.
- First remove apt installed go : $ sudo apt-get remove go
- Download the tar file for linux from the site https://golang.org/dl/
- Execute the command $ sudo tar -C /usr/local -xzf
- In the file ~/.bash_aliases add the following lines:
export GOROOT="/usr/local/go"
export GOBIN="$HOME/go/bin"
mkdir -p $GOBIN
export PATH=$PATH:$GOROOT/bin:$GOBIN
This is all you need to get the current latest version of Go 1.13 that support modules. Note that GOPATH is not defined since it’s not needed anymore with modules.
GOBIN is the directory where go commands will be installed or programs compiled with go install.