安装包/usr/bin/go不是一个目录。

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

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项目目录的根路径,该目录应包含srcpkgbin子目录。请参考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

&quot;go.gopath&quot;: &quot;&lt;paste GOPATH path found from the above terminal command&gt;&quot;,
&quot;go.goroot&quot;: &quot;&lt;paste GOROOT path found from the above terminal command&gt;&quot;

huangapple
  • 本文由 发表于 2017年7月6日 23:07:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/44952719.html
匿名

发表评论

匿名网友

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

确定