go: 无法找到 GOROOT 目录:/usr/bin/go

huangapple go评论103阅读模式
英文:

go: cannot find GOROOT directory: /usr/bin/go

问题

我尝试安装一个包,但是即使我的ROOT目录设置正确,仍然遇到以下问题。

p@p-ubuntu:~/ba/docker-lvm-plugin$ which go
/usr/bin/go
p@p-ubuntu:~/ba/docker-lvm-plugin$ echo $GOROOT
/usr/bin/go
p@p-ubuntu:~/ba/docker-lvm-plugin$ go get github.com/Sirupsen/logrus
go: 无法找到GOROOT目录:/usr/bin/go
英文:

Im trying to install a package but get the below problem even though my ROOT directory is set properly.

p@p-ubuntu:~/ba/docker-lvm-plugin$ which go
/usr/bin/go
p@p-ubuntu:~/ba/docker-lvm-plugin$ echo $GOROOT
/usr/bin/go
p@p-ubuntu:~/ba/docker-lvm-plugin$ go get github.com/Sirupsen/logrus
go: cannot find GOROOT directory: /usr/bin/go

答案1

得分: 3

如果执行go env命令,可能会返回以下内容:

set GOPATH=C:\Users\user\go
set GOROOT=C:\tools\go

GOPATH是什么?

> 创建您的工作区目录,%USERPROFILE%\go。(如果您想使用其他目录,您需要设置GOPATH环境变量;有关详细信息,请参阅《如何编写Go代码》。)

GOROOT是什么?

> 如果您选择的目录不是c:\Go,则必须将GOROOT环境变量设置为您选择的路径。

英文:

If one issues go env then the following could be returned:

set GOPATH=C:\Users\user\go
set GOROOT=C:\tools\go

What is the GOPATH?

> Create your workspace directory, %USERPROFILE%\go. (If you'd like to
> use a different directory, you will need to set the GOPATH environment
> variable; see How to Write Go Code for details.)

What is the GOROOT?

> If you chose a directory other than c:\Go, you must set the GOROOT
> environment variable to your chosen path.

huangapple
  • 本文由 发表于 2017年7月7日 00:08:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/44954007.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定