go - 如何将 Go dep 与 GitLab 子组一起使用

标签 go gitlab godeps

我有一个 Go 项目,它需要来自私有(private) GitLab 存储库(如 git.mydomain.com/myteam/category/subcategory/project.git)的一些依赖项。
但我收到了这个错误。

ensure Solve(): remote repository at https://git.mydomain.com/myteam/category.git does not exist or is inaccessible: : exit status 128

最佳答案

这个问题在 GitLab support tracker 上有详细的讨论。 .
TL;博士;这是(故意)broken for private repos :

Is [your group] private? If so, this is expected behavior, and I would recommend reading the discussion from #1337 (comment 36293613) onwards. In this case, we have decided to maximize security/privacy at the slight expense of usability. The recommended workaround is to specifically add .git to your URL.


我发现的唯一解决方案是使用 go get 's support for .netrc ,解决了这两个问题 dep ,以及现代 Go 模块。
  • 使用 在 GitLab 上创建个人访问 token 接口(interface) 范围:
    enter image description here
  • 创建 ~/.netrc文件:
     machine gitlab.com
         login <your gitlab username>
         password <the token created in step 1>
    
  • 保护您的 .netrc归档一点:
     chmod 600 ~/.netrc
    
  • 利润

  • 现在应该可以工作了:
        dep ensure -add gitlab.com/<company>/<subgroup>/<project>
    
    如果您使用的是私有(private) GitLab 安装,我相信您可以替换 gitlab.com在适用的情况下使用适当的主机名。

    关于go - 如何将 Go dep 与 GitLab 子组一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56670381/

    相关文章:

    c++ - cgo 调用在 C++ 中定义的函数(在命名空间中)

    maven - 如何在 CI 构建中更改 POM 版本?

    apache - 使用 SSL 的 Apache2 上的 Gitlab

    docker - 如何在 docker 容器中使用 nginx-proxy 通过 ssl 安全地运行 Gitlab

    Go 包与 go dep 的依赖关系

    go - 如何从一个字节中解压缩 2、2 和 3 位

    http - 如何在golang中生成查询字符串?

    docker - Godep无法在Docker容器中工作

    go - 运行 dep 时出错确保 : Grouped write of manifest, 锁和 vendor :无法统计 VerifyVendor 声称存在的文件

    go - 具有不同组成的多个结构