2019-05-21 10:57
浏览 569

`go build -mod vendor`无法使用供应商的软件包

When deploying my Go services to Google AppEngine (standard), I receive an errors describing a module version not being found, while everything compiles fine.

The modules are on a private Github instance and checked out to vendor/.

A go build -mod vendor -o /dev/null ./... works in cloud-build-local, locally and in Google Cloud Build. A tag called 'v1.1.0' exists on

gosystem$ git tag
Failed to build app: [go build -o /tmp/staging172777881/usr/local/bin/start .] with env [PATH=/go/bin:/usr/local/go/bin:/builder/google-cloud-sdk/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=f3f56ce621f0 HOME=/builder/home BUILDER_OUTPUT=/builder/outputs DEBIAN_FRONTEND=noninteractive GOROOT=/usr/local/go/ GOPATH=/go GO111MODULE=on GOCACHE=/tmp/cache019702820 GOPATH=/go] failed: err=exit status 1, out="
go: finding v1.1.0
go: finding v1.4.0
go: finding v0.8.1
go: finding v0.0.0-20150907023854-cb7f23ec59be
go: finding v1.5.0
go: finding v1.0.0
go: finding v1.1.0
go: finding v0.0.0-20181031085821-98eec2978e00
go: finding v8.0.4+incompatible
go: finding v0.3.2
go: finding v0.0.0-20180306012644-bacd9c7ef1dd
go: finding v1.0.1
go: finding v1.3.1
go: finding v1.3.0
go: finding v0.0.0-20190204201341-e444a5086c43
go: finding v0.0.0-20190301062529-5545eab6dad3
go: finding v0.0.7
go: unknown revision v1.1.0

A grep -RI 'gosystem@' * reports nothing.

图片转代码服务由CSDN问答提供 功能建议

将我的Go服务部署到Google AppEngine(标准)时,我收到一条错误消息,说明找不到模块版本,

这些模块位于私有Github实例上,并检出到 vendor /

A go build -mod vendor -o / dev / null ./...在本地,本地和Google Cloud Build中都可以使用cloud-build-本地。 在github上存在一个名为“ v1.1.0”的标签 .com / company / gosystem:

  gosystem $ git标签
 无法构建应用:[en build -o / tmp / staging172777881 / usr / local / bin / start。]和env [PATH = / go / bin:/  usr / local / go / bin:/ builder / google-cloud-sdk / bin /:/ usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin主机名 = f3f56ce621f0 HOME = / builder / home BUILDER_OUTPUT = / builder / outputs DEBIAN_FRONTEND = noninteractive GOROOT = / usr / local / go / GOPATH = / go GO111MODULE =在GOCACHE = / tmp / cache019702820 GOPATH = /  go]失败:err =退出状态1,out =“ 
go:查找 v1.1.0 
go:查找 v1.4.0 
go:查找  / pkg / errors v0.8.1 
go:查找 v0.0.0-20150907023854-cb7f23ec59be 
go:查找 v1.5.0 
go:查找  v1.0.0 
go:查找 v1.1.0 
go:查找 v0.0.0-20181031085821-98eec2978e00 
go:查找 v8。  0.4+不兼容
go:查找 v0.3.2 
go:查找 v0.0.0-20180306012644-bacd9c7ef1dd 
go:查找  v1.0.1 
go:查找 v1.3.1 
go:查找 v1.3.0 
go:查找 v0.0.0-20190204201341-  e444a5086c43 
go:查找 v0.0.0-20190301062529-5545eab6dad3 
go:查找 v0.0.7  em@v1.1.0:未知修订版v1.1.0 

grep -RI'gosystem @'* 未报告任何内容。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doubo7131 2019-05-23 13:45

    In the end I was able to make this work by forcing go to use vendor, by adding this to the go.mod:

    replace => ./vendor/
    点赞 评论
  • drztpx8735 2019-05-21 13:33

    Go uses https to fetch versions/dependencies. Even if you use vendor, Go will verify the version anyway. And since is a private repo, git can't get access to it.

    There are few workarounds for this.

    1 - Use ssh:

    git config --global url.ssh://

    2 - Use GitHub token:

    Generate GITHUB_TOKEN here

    export GITHUB_TOKEN=xxx
    git config --global url."https://${GITHUB_TOKEN}".insteadOf ""
    点赞 评论

相关推荐 更多相似问题