英文:
Go installing package /usr/bin/go not a directory
问题
我正在尝试安装一个Go包,但出现了以下错误。
这是我的GOPATH:
p@p-ubuntu:~/ba/docker-lvm-plugin$ echo $GOPATH
/usr/bin/go
包的安装:
p@p-ubuntu:~/ba/docker-lvm-plugin$ go get github.com/Sirupsen/logrus
package github.com/Sirupsen/logrus: mkdir /usr/bin/go: 不是一个目录
英文:
Im trying to install a Go package but having the following error.
Here is my GOPATH
p@p-ubuntu:~/ba/docker-lvm-plugin$ echo $GOPATH
/usr/bin/go
Package install
p@p-ubuntu:~/ba/docker-lvm-plugin$ go get github.com/Sirupsen/logrus
package github.com/Sirupsen/logrus: mkdir /usr/bin/go: not a directory
答案1
得分: 9
你的GOPATH是错误的。它不应该是go二进制文件的路径,而应该是你的go项目目录的根路径,该目录应包含src
、pkg
和bin
子目录。请参考https://stackoverflow.com/questions/7970390/what-should-be-the-values-of-gopath-and-goroot
英文:
Your GOPATH is wrong. It should not be the path to the go binary, it should be the path to the root of your go project directory, which should contain src
, pkg
, and bin
subdirectories. See https://stackoverflow.com/questions/7970390/what-should-be-the-values-of-gopath-and-goroot
答案2
得分: 0
请将GOBIN更改为可用的路径,例如$GOPATH/bin或$GOROOT/bin。
您可以使用go env
命令查看GOBIN的值。
英文:
please change the GOBIN to available path, for example $GOPATH/bin, or $GOROOT/bin
you can see GOBIN with go env
答案3
得分: -1
这对我在Ubuntu上有效:
在终端中运行 -
$ go env
找到在上述命令的输出中提到的GOPATH和GOROOT路径。
在VsCode中打开settings.json,要在VsCode中打开设置-使用Ctrl+Shift+P并搜索
Preferences: Open Settings (JSON)
然后设置以下值
"go.gopath": "<粘贴从上述终端命令中找到的GOPATH路径>",
"go.goroot": "<粘贴从上述终端命令中找到的GOROOT路径>"
英文:
This worked for me in Ubuntu:
Run in the terminal -
$ go env
Find what are the GOPATH and GOROOT paths mentioned in the output given by the above command.
Open settings.json in VsCode, To open settings in VsCode- use Ctrl+Shift+P and search for
Preferences: Open Settings (JSON)
After that set the following values
"go.gopath": "<paste GOPATH path found from the above terminal command>",
"go.goroot": "<paste GOROOT path found from the above terminal command>"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论