dongpao5261 2016-11-04 20:35
浏览 16

为什么“去供应商添加”不能使用修订号

I was getting a compile error which led me to believe that I had the wrong version of a library in my vendor folder. The first task was to determine what revision of the library was correct. I needed to find the version of the library source that contained the string "VolumeCreateRequest". For that I used this trick from the root folder of the library:

git rev-list --all | xargs git grep VolumeCreateRequest

From that I found the version hash: 06f160237426e705ed214a4f087d4aeea32c0a8b:

So then I tried to add that version into my vendor folder go vendor add github.com/docker/docker/...@06f160237426e705ed214a4f087d4aeea32c0a8b

But it doesn't work. When I check the library's version using git it does not report the version I just fetched.

git log -n 1 --pretty=format:"%H"

The vendor.json file also contains the wrong version

so what's up? After carefully reading the docs I see go vender add just silently ignores the @06f160237426e705ed214a4f087d4aeea32c0a8b on the end of my fetch URI.

The correct command is go vendor fetch which supports the @version

govendor fetch github.com/docker/docker/...@06f160237426e705ed214a4f087d4aeea32c0a8b

Another way to accomplish this is to git checkout the version you want of the library, in your GOPATH (i.e. not in your vendor folder), then govendor add the package from your GOPATH

So now I check the git version and we are all good. Then the next problem occurred. Our generate.go file (invoked by go generate) is going in and overwriting the desired version in my vendor.json with what was on my GOPATH.

The sequence in our generate.go is:

//go:generate govendor add +external
//go:generate govendor fetch +missing
//go:generate go vendor sync

This turned out to be wrong because the add would overwrite my changes, then the sync is ineffectual because vendor.json already infected with wrong version.

The correct sequence is this:

//go:generate govendor sync
//go:generate govendor add +external
//go:generate govendor fetch +missing

In this way, your customized vendor.json will sync the vendor folder to what is desired first, and only after that will external and missing dependencies be downloaded.

Finally, several dependencies actually would not compile at all do to platform specific stuff. To cure this, I add these lines in generate.go to remove those broken dependencies, after I sync, add, fetch

//go:generate govendor remove github.com/docker/docker/runconfig
//go:generate govendor remove github.com/docker/docker/libcontainerd
//go:generate govendor remove github.com/docker/libcompose/test
//go:generate govendor remove github.com/Microsoft/...
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测