微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法通过SSH私有嵌套存储库安装go模块

如何解决无法通过SSH私有嵌套存储库安装go模块

复制步骤

  • 安装Go 1.14
  • 在Gitlab中创建一个私人组织
  • 在组织中创建一个私人小组
  • 在子组中创建一个私有存储库
  • 在本地克隆存储库
  • 进入存储库
  • 初始化新的go模块go mod init gitlab.com/myorganisation/mysubgroup/myrepository
  • 提交并推送
  • cd到另一个启用了go模块的存储库
  • 运行go get gitlab.com/myorganisation/mysubgroup/myrepository

出现错误

go get gitlab.com/myorganisation/mysubgroup/repo1: git ls-remote -q https://gitlab.com/myorganisation/mysubgroup.git in /Volumes/CS/go/pkg/mod/cache/vcs/a96c83d4d1395bc931a1a8ac402e8d8e494cc85efa9081cab02316963aa836ed: exit status 128:
        The project you were looking for Could not be found.
        fatal: Could not read from remote repository.
        
        Please make sure you have the correct access rights
        and the repository exists.

解决方法

  1. 〜/ .gitconfig:
    [url "git@gitlab.com:"]
        insteadOf = https://gitlab.com/

1。设置环境:

    GONOPROXY="gitlab.com/mycorp/*"
    GONOSUMDB="gitlab.com/mycorp/*"
    GOPRIVATE="gitlab.com/mycorp/*"
  1. 在go.mod文件中,将子组存储库的路径从“ gitlab.com/myorganisation/mysubgroup/myrepository”更改为“ gitlab.com/myorganisation/mysubgroup/myrepository.git”。所有子组存储库导入路径均相同。

  2. 转到需要上述子组回购的先前存储库,然后调用“ go get -insecure gitlab.com/myorganisation/mysubgroup/myrepository.git”

之后,必须更新go.mod,一切都会开始正常运行。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。