猿问

`go build -mod vendor` 无法使用 vendored 包

将我的 Go 服务部署到 Google AppEngine(标准)时,我收到一条错误,描述未找到模块版本,但一切编译正常。


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


Ago build -mod vendor -o /dev/null ./...在 cloud-build-local、本地和 Google Cloud Build 中工作。github.com/company/gosystem 上存在一个名为“v1.1.0”的标签:


gosystem$ git tag

v0.0.1

v0.0.2

v0.0.3

v1.0.0

v1.1.0

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 github.com/pquerna/otp v1.1.0

go: finding github.com/gin-gonic/gin v1.4.0

go: finding github.com/pkg/errors v0.8.1

go: finding github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be

go: finding github.com/gosimple/slug v1.5.0

go: finding github.com/boombuler/barcode v1.0.0

go: finding github.com/company/gosystem v1.1.0

go: finding github.com/oblq/i18n v0.0.0-20181031085821-98eec2978e00

go: finding github.com/go-pg/pg v8.0.4+incompatible

go: finding golang.org/x/text v0.3.2

go: finding github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd

go: finding github.com/modern-go/reflect2 v1.0.1

go: finding github.com/golang/protobuf v1.3.1

go: finding github.com/stretchr/testify v1.3.0

go: finding github.com/ugorji/go/codec v0.0.0-20190204201341-e444a5086c43

go: finding github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3

go: finding github.com/mattn/go-isatty v0.0.7

go: github.com/company/gosystem@v1.1.0: unknown revision v1.1.0

Agrep -RI 'gosystem@' *什么也没报告。


BIG阳
浏览 170回答 2
2回答

慕田峪4524236

最后,我能够通过强制使用 go 来完成这项工作vendor,方法是将其添加到go.mod:replace github.com/company/gosystem => ./vendor/github.com/company/gosystem

繁星点点滴滴

Go 使用 https 来获取版本/依赖项。即使你使用 vendor,Go 也会验证版本。由于github.com/venclave/gosystem是私人仓库,git 无法访问它。几乎没有解决方法。1 - 使用 ssh:git config --global url.ssh://git@github.com/venclave.insteadOf https://github.com/venclave2 - 使用 GitHub 令牌:在此处生成 GITHUB_TOKEN https://github.com/settings/tokens。export GITHUB_TOKEN=xxx git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/venclave".insteadOf "https://github.com/venclave"
随时随地看视频慕课网APP

相关分类

Go
我要回答