go: 找不到 GOROOT 目录:/usr/bin/go

标签 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: cannot find GOROOT directory: /usr/bin/go

最佳答案

如果发出 go env 则可能会返回以下内容:

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

什么是 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.)

什么是 GOROOT

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

关于go: 找不到 GOROOT 目录:/usr/bin/go,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44954007/

相关文章:

从 os.Args[1] 读取时 golang 文件名太长错误

go - 无法识别的导入路径

go - go-colly:如何在c.OnResponse中获取HTML标题,以便填充结构?

pointers - reflect.Pointer() 返回值不是值地址

Go 不能同时添加 accept 和 content-type headers

select - 为什么这个 select 在实际执行第一个 case 时总是运行 default case?

json - 从 Java 到 Golang : Unmarshaling Polymorphic JSON

inheritance - Golang 继承和方法覆盖

go - 如何跳过失败的测试

json - 为什么 Go json.Marshal 拒绝这些结构标签? json 标签的正确语法是什么?