英文:
Godep restore doesn't use the code saved in _workspace
问题
我一段时间前开始使用godep
,但我觉得我没有理解它的原理,可能完全使用错误。
我以为godep
会维护_workspace
,以便在某些修订版/项目被删除或不可用时,有一个本地副本。但是godep restore
似乎根本不使用_workspace
。
而且,第二次调用godep save
并没有更新_workspace
,只更新了Godeps.json
。
我错过了什么吗?
更新:
为了解释我的问题,我将Godeps.json中的一个修订版更改为无效的修订版"1",然后运行了godep restore
。以下是我收到的错误信息:
$GOPATH/bin/godep restore
# cd /home/iliga/gopath/src/github.com/jinzhu/gorm; git pull --ff-only
From https://github.com/jinzhu/gorm
a97a508..087b708 master -> origin/master
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.
git pull <remote> <branch>
# cd /home/iliga/gopath/src/github.com/jinzhu/gorm; git checkout 1
error: pathspec '1' did not match any file(s) known to git.
godep: restore: exit status 1
如上所述,我希望不会出现错误,并且godep只会简单地从_workspace中复制代码。
英文:
I started using godep
a while ago but I think I'm failing to understand the principal, and I may be using it incorrectly entirely.
I thought godep
maintains _workspace
in order to have a local copy of the packages in case some revisions/projects are removed or become unavailable. But godep restore
doesn't seem to use _workspace
at all.
Also, calling godep save
for the second time didn't update _workspace
, only Godeps.json
.
What am I missing?
UPDATE:
To explain my question I changed one of the revisions in my Godeps.json to an invalid revision "1" and ran godep restore
. Here's the error I got:
$GOPATH/bin/godep restore
# cd /home/iliga/gopath/src/github.com/jinzhu/gorm; git pull --ff-only
From https://github.com/jinzhu/gorm
a97a508..087b708 master -> origin/master
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.
git pull <remote> <branch>
# cd /home/iliga/gopath/src/github.com/jinzhu/gorm; git checkout 1
error: pathspec '1' did not match any file(s) known to git.
godep: restore: exit status 1
As explained above, I would expect there to be no error and for godep to simply copy the code from _workspace.
答案1
得分: 2
"godep restore"不使用_workspace。它会读取Godeps.json文件,并将您的依赖项检出到GOPATH中。
要使用_workspace,您需要在go命令前加上godep前缀,例如"godep go build"、"godep go test"。
英文:
"godep restore" does not use _workspace. It reads Godeps.json and check out your dependencies to GOPATH.
To use _workspace, you run go command prefixed with godep, like "godep go build", "godep go test".
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论