执行时
go get bitbucket.org/../..
我收到这个错误
yash.jain projectname % go get bitbucket.org/../..
go: bitbucket.org/../..
https://api.bitbucket.org/2.0/repositories/../..?fields=scm: 403 Forbidden
go: error loading module requirements
Run Code Online (Sandbox Code Playgroud)
我尝试过的
设置 ssh 密钥(按预期工作,通过推送和拉取代码进行测试)
将 go 环境变量设置为:
GOPRIVATE=""
GOPROXY="direct"
GOSUMDB="off"
Run Code Online (Sandbox Code Playgroud)
.gitconfig 看起来像这样
[url "git@bitbucket.org:"]
insteadOf = https://bitbucket.org/
[user]
email = yash.jain@company.in
name = yashjain
Run Code Online (Sandbox Code Playgroud)
向 ssh-agent 添加密钥
ssh-add -l
ssh-add -k
Run Code Online (Sandbox Code Playgroud)
.ssh/config 文件看起来像这样
Host bitbucket.org
HostName bitbucket.org
User git
IdentityFile ~/.ssh/id_rsa
UseKeychain yes
StrictHostKeyChecking no
Run Code Online (Sandbox Code Playgroud)
尽管如此,我还是遇到了同样的错误。如果我做错了什么,请告诉我。
这些是我尝试使其发挥作用的步骤。
ssh.GOPRIVATE=bitbucket.org/<orgname>/**是允许组织的所有回购。
经过这两个步骤后,我就可以导入包了。
注意:Sourcetree 仅适用于 Mac 和 Windows。
使用命令行: 对于 Linux/Mac/Windows:
git config --global url."git@bitbucket.org:".insteadOf "https://bitbucket.org/"GOPRIVATE=bitbucket.org/<orgname>/*更新404即使经过上述配置,
您也可能会收到错误。
Error
reading https://api.bitbucket.org/2.0/repositories/xyz/privaterepo?fields=scm: 404 Not Found
Run Code Online (Sandbox Code Playgroud)
Bitbucket 最近更新了其私有存储库的 API,因此某些 golang 版本出现问题。
无权访问私有存储库的用户将收到 404(未找到)响应代码,而不是 403(禁止)响应代码,以掩盖给定 URL 路径中私有存储库的存在。
推出这些更改将破坏 Go 的早期版本,因为 go 命令依赖于 403 响应来获取 Bitbucket Cloud 上托管的存储库。
为确保您不会遇到任何问题,请将 GoLang 更新到最新版本。
- 确保您使用的是受支持的 GoLang 版本:1.18、1.17 或 1.16。
- 如果您使用的是 1.17 或 1.16,请确保您使用的是最新补丁(1.17.7 或 1.16.14)
该规定将于 2022 年 6 月 1 日起生效。