Golang installation

和自甴很熟 提交于 2019-12-14 03:35:27

问题


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?)?


回答1:


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:

export PATH=$PATH:/usr/local/go/bin

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.




回答2:


There are paths which needs to be set correctly for you go installation to work

  1. GOROOT points to directory where go is installed

    export GOROOT=/usr/lib/go

  2. GOPATH points to you workspace directory

    export GOPATH=$HOME/go

  3. These paths need to be added in global path variable.

    export PATH=$PATH:$GOROOT/bin




回答3:


You need to put the go executable in your system path. which you can do by

export PATH=$PATH:/etc/usr/go/bin

You can put the same in /home/user/.profile



来源:https://stackoverflow.com/questions/50554817/golang-installation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!