Bitbucket 上的 Go mod 私人仓库
时间:2024-04-13
浏览:266
作者:佚名
本篇文章给大家分享《Bitbucket 上的 Go mod 私人仓库》,覆盖了Golang的常见基础知识,其实一个语言的全部知识点一篇文章是不可能说完的,但希望通过这些问题,让读者对自己的掌握程度有一定的认识(B 数),从而弥补自己的不足,更好的掌握它。
我的工作中有一个项目要做,我们正在使用 bitbucket。所以我们的所有存储库都是这样的:
bitbucket.org/company/project 这里没有什么新内容。
我创建了一个名为 go-tools 的存储库,他的模块名称是 bitbucket.org/company/go-tools ,他的路径是 bitbucket.org/company/go-tools
按照这篇中等文章,我可以实现 go mod tidy
package whatever
import (
"bitbucket.org/company/go-tools"
"bitbucket.org/company/go-tools/env"
// and so on ...
)
当我尝试用“company.com”替换“bitbucket.org/company”时出现问题,因为我们希望用我们的公司名称代替 bitbucket。
所以我的模块名称变为 company.com/go-tools 而不是 bitbucket.org/company/go-tools
我的进口变成:
package whatever
import (
"company.com/go-tools"
"company.com/go-tools/env"
// and so on ...
)
我已将 goprivate 设置为使用 bitbucket,并将 git 配置为使用 bitbucket 而不是 company.com
git config --global url."https://{username}:{app password}@bitbucket.com/company".insteadOf "https://company.com"
go env -w GOPRIVATE=bitbucket.org/company
从那里我只收到 404 错误,告诉我找不到我的包。
有人知道为什么吗?我是否误解了什么?
注意:我也读过这篇文章
解决方案
感谢@adrian 的回复,这至少回答了我的部分问题。 我更多的是寻找一种直接获取“company.com/whatever”的方法,但这没关系。
因此,如果我理解正确,我需要先 go 获取 bitbucket.org/company/whatever,然后 go mod edit -replace bitbucket.org/company/whatever=company.com/whatever
谢谢
文中关于的知识介绍,希望对你的学习有所帮助!若是受益匪浅,那就动动鼠标收藏这篇《Bitbucket 上的 Go mod 私人仓库》文章吧,也可关注golang学习网公众号了解相关技术文章。
本文内容来源于互联网,如有侵权请联系删除。
近期热门
站内热门
最新文章
热门专题
