英文:
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.
(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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论