英文:
How to add dependency to godep.json?
问题
我在将依赖项添加到Godeps.json
文件时遇到了困难。我认为我搞乱了GOPATH
。我尝试了各种警告上的建议,但都没有起作用。
我的GOPATH
是/Users/sarath/project
。
which go
的输出是/usr/local/bin/go
。如果我尝试运行godep save ./...
,它会给我以下警告:
godep: [WARNING]: godep should only be used inside a valid go package directory and
godep: [WARNING]: may not function correctly. You are probably outside of your $GOPATH.
godep: [WARNING]: Current Directory: /Users/sarath/project
godep: [WARNING]: $GOPATH: /Users/sarath/project
godep: Unable to find SrcRoot for package .
我的pkg
文件夹位于/Users/sarath/project
下。
英文:
I'm having hard time to add a dependency to the Godeps.json
file. I think I've messed up the GOPATH
. I tried various suggestions on the warnings but none of them worked for me.
My GOPATH is /Users/sarath/project
.
which go
is /usr/local/bin/go
. If I try to do godep save ./...
, it is giving me the following warning:
godep: [WARNING]: godep should only be used inside a valid go package directory and
godep: [WARNING]: may not function correctly. You are probably outside of your $GOPATH.
godep: [WARNING]: Current Directory: /Users/sarath/project
godep: [WARNING]: $GOPATH: /Users/sarath/project
godep: Unable to find SrcRoot for package .
I have my pkg
inside the /Users/sarath/project
.
答案1
得分: 6
那绝对行不通。GOPATH不仅仅是某个项目的路径;它是一个包含bin
、pkg
和src
目录的根目录;src
目录包含了以包名命名的项目目录。所以你应该从你的项目目录中运行godep
,根据你当前的GOPATH,这个目录应该是/Users/sarath/project/src/<repopath>
,例如/Users/sarath/project/src/github.com/sarath/myproject
。
英文:
That definitely won't work. GOPATH isn't just the path of some project; it's the root of a directory, which contains bin
, pkg
, and src
directories; the src
directory contains package-named directories for projects. So you should be running godep
from your project directory, which (given your current GOPATH) should be /Users/sarath/project/src/<repopath>
- e.g. /Users/sarath/project/src/github.com/sarath/myproject
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论