为什么Go Mod整洁不适合Bitbucket

发布于 2025-02-08 09:21:13 字数 714 浏览 2 评论 0原文

我试图将私人存储库用作GO库。

每当我尝试跑步时,我都会发现这种错误,

>go get bitbucket.org/myworkspace/myRepo
go get bitbucket.org/myworkspace/myRepo: reading https://api.bitbucket.org/2.0/repositories/myworkspace/myRepo?fields=scm: 404 Not Found

我发现我发现了多个建议来解决此问题,而git config而不是重新列出url,但它不起作用,这似乎都假设将通过git克隆库存储库,而不是API。

我正在运行Linux的同事,尝试了此操作并起作用,而且它似乎都不使用Api.bitbucket.org而不是BitBucket.org。

我已经尝试调用 https://api.biti.bitbucket.org/2.0 /储存库/myworkspace/myrepo?fields = scm 通过失眠,带有凭证,我可以将存储库返回。

为什么要使用Windows上的Bitbucket API,我该如何使用凭据,以便找到仓库?

I'm attempting to use private repositories as go libraries.

Whenever i try to run go get og god mod tidy, i get this kind of error

>go get bitbucket.org/myworkspace/myRepo
go get bitbucket.org/myworkspace/myRepo: reading https://api.bitbucket.org/2.0/repositories/myworkspace/myRepo?fields=scm: 404 Not Found

I've found multiple suggestions to fix this, with git config insteadOf url reqriting, but it doesn't work, and it all seems to assume that go will clone the library repo via git, and not the api.

My colleague who is running Linux, tried this and it worked, and at no point does it appear to use api.bitbucket.org instead of just bitbucket.org.

I've tried calling https://api.bitbucket.org/2.0/repositories/myworkspace/myRepo?fields=scm via Insomnia, with credentials, and i get the repo back just fine.

Why does go use the bitbucket api on windows, and how can i have it use credentials, so it can find the repo ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ゝ偶尔ゞ 2025-02-15 09:21:14

这是由于a Bitbucket进行的更改(从2022年6月1日推出):

推出这些更改将破坏GO的先前版本,这是因为GO命令依赖于对Bitbucket Cloud上托管的获取存储库的403响应。这意味着使用私有存储库的旧版本的用户,例如CI/CD构建具有GO依赖关系,将遇到404个错误。

GO已更新以支持这些更改;版本1.18包括更改,但是如果您正在运行较早的版本,则可能需要升级到较晚的修订版(更改为1.17.71.16.14)。相关的GO问题在这里问题)。

为什么要使用Windows上的Bitbucket API ...

GO使用API​​来确定Bitbucket Repo是使用git还是在使用git或mercurial(bitbucket是对Mercurial的支持)。

如评论中所述,我发现新的 git凭证管理器删除了先前访问私人位置存储库所需的解决方法的需求。使用凭据管理器和设置Goprivate就是所需的一切。

This is due to a change made by Bitbucket (rolling out from June 1st 2022):

Rolling out these changes will break previous versions of Go due to the fact that the go command relies on a 403 response to fetch repositories hosted on Bitbucket Cloud. This means that users who use older versions of Go with private repositories, for example CI/CD builds with Go dependencies, will run into 404 errors.

Go has been updated to support these changes; version 1.18 includes the change but if you are running an earlier version you may need to upgrade to a later minor revision (change is in 1.17.7 and 1.16.14). The relevant Go issue is here (the aim of the change is something different but it resolves the issue).

Why does go use the bitbucket api on windows...

Go was using the API to determine if the Bitbucket repo was using Git or Mercurial (Bitbucket is dropping support for Mercurial).

As mentioned in the comments I've found that the new Git Credential Manager removes the need for the workarounds previously required to access private Bitbuicket repos. Using the credential manager and setting GOPRIVATE was all that was needed..

差↓一点笑了 2025-02-15 09:21:14

您可以首先使用命令导出Goporvate =<远程模块名称>导出私有存储库。然后,您可以运行命令env git_terninal_prompt = 1 go get<远程模块名称>,以便如果未配置凭据,您会得到一个提示。

You can first export the private repository with the command export GOPRIVATE=<remote module name>. Then you can run the command env GIT_TERMINAL_PROMPT=1 go get <remote module name> so that if the credentials are not configured, you get a prompt.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文