无法通过SSH(私有嵌套存储库)安装go模块 [英] Unable to install go module via SSH (private nested repository)

查看:106
本文介绍了无法通过SSH(私有嵌套存储库)安装go模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

复制步骤

  • 安装Go 1.14
  • 在Gitlab中创建一个私人组织
  • 在组织中创建一个私人小组
  • 在子组中创建一个私有存储库
  • 在本地克隆存储库
  • cd到存储库
  • 初始化新的go模块go mod init gitlab.com/myorganisation/mysubgroup/myrepository
  • 提交并推送
  • cd到另一个启用了go模块的存储库
  • 运行go get gitlab.com/myorganisation/mysubgroup/myrepository
  • Install Go 1.14
  • Create a private organisation in Gitlab
  • Create a private subgroup in the organisation
  • Create a private repository in the subgroup
  • Clone the repository locally
  • cd to the repository
  • Initialise new go module go mod init gitlab.com/myorganisation/mysubgroup/myrepository
  • Commit and push
  • cd to another go modules enabled repository
  • Run 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".所有子组存储库导入路径均相同.

  1. In go.mod file change path of your subgroup repo from "gitlab.com/myorganisation/mysubgroup/myrepository" to "gitlab.com/myorganisation/mysubgroup/myrepository.git". Same for all subgroup repo import paths.

转到需要上述子组存储库的以前的存储库,然后调用"go get -insecure gitlab.com/myorganisation/mysubgroup/myrepository.git"

Go to your previous repository that requires above subgroup repo and call "go get -insecure gitlab.com/myorganisation/mysubgroup/myrepository.git"

之后,必须先更新go.mod,一切才能正常运行.

After that go.mod must be updated and everything will start work fine.

这篇关于无法通过SSH(私有嵌套存储库)安装go模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆