sudo snap install go --classic
# open these files `nano ~/.profile` or `nano ~/.zshrc` and add below at the end
export GOPATH=$HOME/goproj
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
# refresh file using
`source ~/.profile` or `source ~/.zshrc`
go1.11.2.linux-amd64.tar.gz
wget https://dl.google.com/go/go1.11.2.linux-amd64.tar.gz
sha256sum go1.11.2.linux-amd64.tar.gz
sudo tar -xvf go1.11.2.linux-amd64.tar.gz
sudo mv go /usr/local
You need to set GOROOT, GOPATH and PATH variables.
- GOROOT is the location where Go package system binaries are installed.
- GOPATH is your project work directory.
- PATH is where your system will look for go binaries when you type the go command.
Add the following lines in your ~/.profile with any editor gedit ~/.profile
or gedit ~/.zshrc
export GOROOT="/usr/local/go"
export GOPATH="$HOME/goproj"
export PATH="$GOPATH/bin:$GOROOT/bin:$PATH"
and save it and then refresh the source file with source ~/.profile
or source ~/.zshrc
To verify it's install ?
$ go version
Now verify the variables are set correctly by running go env :
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/muhammadtaqi/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/muhammadtaqi/go"
GORACE=""
GOROOT="/usr/local/go"
<output truncated for brevity>