无法在存储库的子目录中创建Go语言包

问题描述 投票:0回答:1

我在私有 GitLab 上的多个子目录下创建了包含 Go 语言包的存储库。

存储库的层次结构如下。

https://mygitlab.example.com/grand-parent-org/parent-org/child-org/myrepository.git

此外,库的层次结构如下。

https://mygitlab.example.com/grand-parent-org/parent-org/child-org/myrepository/golib/go.mod

在这种情况下,我最初假设库中的 go.mod 上的包名称为

mygitlab.example.com/grand-parent-org/parent-org/child-org/myrepository/golib
,但无法成功 go get。

我尝试了该命令。

go get mygitlab.example.com/grand-parent-org/parent-org/child-org/myrepository/golib

执行时,它将搜索

mygitlab.example.com/grand-parent-org.git
mygitlab.example.com/grand-parent-org/parent-org.git
作为存储库,但不会通过 go get 搜索更深层次的存储库。

经过多方研究,发现库端go.mod等设置为即可稳定使用

mygitlab.example.com/grand-parent-org/parent-org/child-org/myrepository.git/golib
当go get完成或者导入源代码来使用该库时,它的写法如下。

import "mygitlab.example.com/grand-parent-org/parent-org/child-org/myrepository.git/golib"

  • 这种形式的想法作为 Go 封装操作是否不合适?
  • 我想知道在多个子目录下的存储库中的更多子目录下创建 go 包的最佳实践?
  • 我想知道是否有一种方法可以指定go语言考虑递归授予.git的层次结构选项?
  • 目前,在这种形式下,在使用该库的一侧在 go.mod 中指定版本将会失败。我想知道有什么好用的方法吗?
go gitlab go-modules
1个回答
0
投票

在 GitLab 中,未经身份验证的 https 访问无法看到比顶级组更深的

要么不使用子组(GitHub 没有子组也能正常工作),要么使用身份验证

对于后者,请阅读“将凭证传递到私有存储库”。

© www.soinside.com 2019 - 2024. All rights reserved.