当使用godep更新golang依赖项后,如何构建/安装?

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

golang and godep : Build\install after a golang dependency update when using godep?

问题

我已经按照 https://github.com/tools/godep 上的说明进行了依赖更新,但是当我构建/安装使用修改后的版本时,Godeps/_workspace/pkg 中的依赖并没有更新。

所以我执行了以下步骤:

go get github.com/golang/glog
godep save
godep go install

我可以看到:

  1. Godeps/_workspace/pkg/linux_amd64/github.com/golang/glog.a 中的修改时间戳
  2. Godeps/Godeps.json 中的 rev commit 值

但是现在当我想要更新时,我按照以下步骤进行:

go get github.com/golang/glog
godep update github.com/golang/glog
godep go install

我观察到以下情况:

  1. Godeps/Godeps.json 中的 rev commit 已经更新
  2. Godeps/_workspace/src/github.com/golang/ 的源代码已更新
  3. 但是 Godeps/_workspace/pkg/linux_amd64/github.com/golang/glog.a 的文件时间戳没有更新,因此我们仍在使用先前的版本

我认为我应该为 pkg 和 bin 添加一个 .gitignore 条目,这意味着我们在进行全新的 git 克隆时会进行清理构建。

我知道在执行 godep go install 命令之前,我可以在 pkg 和 bin 目录中执行 rm -r 命令。

这是预期的行为吗?

提前感谢!
Pat

英文:

I have followed the instructions @ https://github.com/tools/godep regarding updating a dependency but when I go to build\install using the altered version it has not been updated within Godeps/_workspace/pkg

So I have

go get github.com/golang/glog
godep save
godep go install

and I can see

  1. The modification timestamp in Godeps/_workspace/pkg/linux_amd64/github.com/golang/glog.a
  2. The rev commit value in Godeps/Godeps.json

but now when I want to update I follow the instructions

go get github.com/golang/glog
godep update github.com/golang/glog
godep go install

I observe the following

  1. The Godeps/Godeps.json rev commit has been updated
  2. Godeps/_workspace/src/github.com/golang/ source is updated
  3. But the file timestamp for odeps/_workspace/pkg/linux_amd64/github.com/golang/glog.a is not updated hence we are using the previous version

I believe I should add a .gitignore entry for pkg and bin, which means we would do a clean build on a fresh git clone

I know I could do a rm -r on both the pkg and bin directories before the godep go install command

Is this expected behavior ?

Thanks in advance
Pat

答案1

得分: 0

FYI

自从golang v1.4版本以来,我现在可以在go install命令中使用-a标志,因为它不再尝试重新构建标准库,详见v1.4版本发布说明中关于build -a标志的更改部分。

显然,在v1.4之前不适用,因为它将尝试重新构建标准库包。

英文:

FYI

Since golang v1.4 I can now use the -a flag for the go install command, since it now longer tries to rebuild the standard library, see the v1.4 release notes section on the change to the build -a flag

Obviously this does not apply in pre v1.4 as it will attempt to rebuild the standard library packages

huangapple
  • 本文由 发表于 2014年11月13日 07:40:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/26898766.html
匿名

发表评论

匿名网友

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

确定