不在BitBucket上下载存储库中的模块
时间:2024-02-24
浏览:320
作者:佚名
亲爱的编程学习爱好者,如果你点开了这篇文章,说明你对《不在BitBucket上下载存储库中的模块》很感兴趣。本篇文章就来给大家详细解析一下,主要介绍一下,希望所有认真读完的童鞋们,都有实质性的提高。
在 bitbucket.org 中有一个 git 存储库
reponame/
.git/
integration1/
integration2/
integration-common/
└── util
├── go.mod
└── readascii.go
模块目录是 git 存储库的子目录。该存储库标记为 v0.0.1。
这是 go.mod
module bitbucket.org/orgname/reponame/integration-common/util go 1.14
当我对此模块执行 go get 时,出现以下错误
go get bitbucket.org/orgname/reponame/integration-common/[email protected] go: downloading bitbucket.org/orgname/reponame v0.0.1 go get bitbucket.org/orgname/reponame/integration-common/[email protected]: module bitbucket.org/orgname/[email protected] found, but does not contain package bitbucket.org/orgname/reponame/integration-common/util
如果我使用网络浏览器查看,我可以在 bitbucket.org 中的 v0.0.1 标签下看到 integration-common/util/ 目录。 go.mod 的内容如上所示。
更奇怪的是 go get 确实设法下载存储库中的其他目录(integration1/ 和 integration2/)。由于某种原因,它认为 v0.0.1 不包含 integration-common/ 目录,尽管 bitbucket 在该标签中显示了该目录。
我使用 ssh 下载,而不是 https,因为 https 在我们的 bitbucket 存储库上需要 2fa:
~/.gitconfig:
url "[email protected]:"]insteadOf = https://bitbucket.org/
我知道 bitbucket 在使用 go get 时很奇怪。有什么我错过的,或者这是 go get 和 bitbucket 的错误吗?
解决方案
标签 v0.0.1 适用于存储库根目录的模块 (bitbucket.org/orgname/reponame)。
integration-common/util 子目录中的 go.mod 文件导致该子目录成为其自己的模块,具有自己的版本空间和自己的版本标记集,其形式需要为 integration-common /util/v0.0.1(参见 https://golang.org/doc/modules/managing-source#tmp_4)。
即:
v0.0.1标记适用于模块bitbucket.org/orgname/reponame,该模块不包含该软件包,因为它位于包含另一个go.mod文件的目录下。- 模块
bitbucket.org/orgname/reponame/integration-common/util存在并包含该软件包,但它没有版本v0.0.1,因为子目录模块的版本标记需要与以下内容对应的显式前缀该子目录。
一般来说,最简单的方法是在存储库根目录中只有一个 go.mod 文件,并避免在子目录中嵌套其他模块。
文中关于的知识介绍,希望对你的学习有所帮助!若是受益匪浅,那就动动鼠标收藏这篇《不在BitBucket上下载存储库中的模块》文章吧,也可关注golang学习网公众号了解相关技术文章。
本文内容来源于互联网,如有侵权请联系删除。
近期热门
站内热门
最新文章
热门专题
