无法通过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,一切都会开始正常运行。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...