Godep restore不使用_workspace中保存的代码。

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

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".

huangapple
  • 本文由 发表于 2015年2月25日 02:24:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/28703391.html
匿名

发表评论

匿名网友

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

确定