问题描述
我们正在使用专用的Bitbucket存储库来管理我们的Go库.通过将insteadOf
配置用于git
,例如在这个 Stackoverflow答案中,我们已经完成了Go版本1.12的工作.版本1.13和1.14不再起作用.我们看到这样的错误:
We are using private Bitbucket repositories to manage our Go libraries. By using the insteadOf
config for git
as described e.g. in this Stackoverflow answer, we had a working build up to Go version 1.12. Versions 1.13 and 1.14 do not work any more. We are seeing errors like this:
$ go vet ./...
go: downloading bitbucket.org/travelloapp/golibs v1.0.42
usercache/usercache.go:6:2: bitbucket.org/travelloapp/golibs@v1.0.42: verifying module: bitbucket.org/travelloapp/golibs@v1.0.42: reading https://sum.golang.org/lookup/bitbucket.org/travelloapp/golibs@v1.0.42: 410 Gone
server response:
not found: bitbucket.org/travelloapp/golibs@v1.0.42: reading https://api.bitbucket.org/2.0/repositories/travelloapp/golibs?fields=scm: 403 Forbidden
server response: Access denied. You must have write or admin access.
常见问题解答"建议设置curl
的~/.netrc
文件.我使用Bitbucket的"App Password"(应用密码)特征.它不会改变结果.我已经添加了bitbucket.org
和api.bitbucket.org
作为主机名.
The Go FAQ proposes to set up curl
's ~/.netrc
file. I've done that, using Bitbucket's "App Password" feature. It is not changing the result. I have added both bitbucket.org
and api.bitbucket.org
as host names.
我可以直接使用curl
测试文件设置是否正确:
I can test the file setup is correct with curl
directly:
$ curl -n https://api.bitbucket.org/2.0/repositories/travelloapp/golibs?fields=scm
{"scm": "git"}
作为记录:尽管有Bitbucket错误消息.存储库读取访问权限似乎是唯一需要的权限,尽管我也尝试过启用所有权限.
For the record: despite the Bitbucket error message. repository read access seems to be the only permission required, although I have tried with all permissions enabled as well.
我错过了什么吗?为什么适用于Go 1.12的方法不再适用于更高版本?
Am I missing something? Why did the approach that works for Go 1.12 stop working for higher versions?
我当前正在使用:
$ go version
go version go1.14.2 linux/amd64
$ git version
git version 2.17.1
$ curl --version
curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.1 zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
Release-Date: 2018-01-24
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL
当Go 1.13发布时,我们首先遇到了这个问题,此刻,我们仍然将所有环境都保持在1.12.
We encountered the issue first when Go 1.13 came out, at the moment we are still holding all environments back on 1.12.
推荐答案
由于go@1.13的行为类似于以前的版本,因此您需要设置私有存储库的GOPRIVATE 环境变量
Since go@1.13 to have a behavior similar to previous versions, you need to set GOPRIVATE environmental variable for private repositories
这篇关于如何将Go与Bitbucket私有存储库一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!