安装后无法使用的Go包

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

Go package unusable after installation

问题

最近我在我的Go入门项目中安装了一个名为go-bindata的新包,我按照安装指南进行了操作,但是在我尝试运行命令后,出现了以下错误信息。

$ go-bindata
bash: go-bindata: command not found

我在stackoverflow上找到了一个类似的问题,并且给出的解决方案是设置$GOPATH。我使用的是Windows操作系统,并且已经将我的$GOPATH配置在$PATH中,如下图所示。我不知道哪一步出错了。

环境变量和路径

(对于附加的图片造成的不便我感到抱歉,因为我不能直接在帖子中附加图片。)

英文:

I recently installed a new package for one of my Go introductory projects named go-bindata, I have followed the installation guide, but after I tried to run the command, this showed up.

$ go-bindata
bash: go-bindata: command not found

I have referred to one similar problem on stackoverflow, and the solution given is setting $GOPATH, I'm on a windows operating system, and I have already configured my $GOPATH in $PATH as the image shown below, I don't know which step I got wrong.

Environment vairiable & Path

(I'm sorry for the inconvience on the attached image since I'm not allowed to attach an image directly to the post.)

答案1

得分: 7

要使用现代版本的Go进行安装,您应该运行以下命令:

go install github.com/go-bindata/go-bindata/go-bindata@latest

该命令将编译并将二进制文件放入您计算机上的GOPATH\bin文件夹中,因此如果您希望能够从任何位置运行它,您应该将GOPATH\bin添加到您的PATH中。

然后尝试运行它:

go-bindata

这是因为项目目录结构的重复有点尴尬。第一个go-bindata是GitHub用户名,第二个是项目名称,第三个是程序的主包所在位置。

英文:

To perform the installation with modern versions of Go, you should run:

go install github.com/go-bindata/go-bindata/go-bindata@latest

This command will compile and put the binary into the GOPATH\bin folder on your machine, so if you want to be able to run it from anywhere, you should add GOPATH\bin to your PATH.

And then try and run it:

go-bindata

It's a bit awkward repetition, because of the project directory structure. The first go-bindata is github username, the second is the project name and the third is where the main package of the program is to be found.

huangapple
  • 本文由 发表于 2022年4月14日 13:08:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/71866762.html
匿名

发表评论

匿名网友

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

确定