I just followed the installation guide for golang (ubuntu 16). I extracted the archive at /etc/usr I added env variable in /home/user/.profile I just tested a basic go build on the hello world code.
I get the following error:
The program 'go' is currently not installed. You can install it by typing: sudo apt install golang-go
Why does it ask me to install it (again?)?
There are paths which needs to be set correctly for you go installation to work
GOROOT points to directory where go is installed
export GOROOT=/usr/lib/go
GOPATH points to you workspace directory
export GOPATH=$HOME/go
These paths need to be added in global path variable.
export PATH=$PATH:$GOROOT/bin
You need to put the go executable in your system path. which you can do by
You can put the same in /home/user/.profile
The location of the binary
go
is not in your path. Ubuntu does not find it and suggests to install it. Add this line to your file/etc/profile
, or better$HOME/.profile
:This is documented in the docs: https://golang.org/doc/install#install
If you want to try this solution before editing any files, you can just execute the above command and try to execute the
go
command in the shell.