【问题标题】:"go get" private github repository using two factor authentication使用两因素身份验证“去获取”私有 github 存储库
【发布时间】:2020-08-25 13:25:51
【问题描述】:

我们的私人组织 GitHub 帐户通过身份验证

  1. 双重身份验证

  2. 个人访问令牌

当我尝试通过私人组织 Github 中的 go get 获取 go 模块时

unrecognized import path "<repo>/api?go-get=1: no go-import meta tags ()

我找到了一个类似的帖子,但解决方案对我不起作用

What's the proper way to "go get" a private repository?

另外,我发现 https://medium.com/@dayakar88/a-guide-to-solve-no-go-import-meta-tags-for-private-repositories-with-go-modules-6b9237f9c9f 似乎适合我的情况,但我无法理解解决方案

【问题讨论】:

    标签: go go-modules


    【解决方案1】:

    我通过设置 go for non-public modules 将 Github 帐户作为值传递来完成此操作。

    并通过配置代理来获取它directly

    或者,您可以强制 go get 命令在 SSH 的 URL 中使用 Github 个人访问令牌(如果您让 http:// 会失败,因为它无法访问存储库)

    EXPORT GOPRIVATE=github.com/YOURACCOUNT && \
    EXPORT GOPROXY=direct && \
    git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf https://github.com/
    

    【讨论】:

    • https://${GITHUB_TOKEN}@github.com/ 你确定我们这里只标记吗?我
    • 只需要token,你可以随意添加你的github用户名
    • 我已经尝试了以下方式export GOPRIVATE=github.developer.allianz.io/&lt;my-account-name&gt; export GOPROXY=direct go get -u &lt;pkgname&gt;但仍然是同样的错误
    • 你必须在 URL 中定义 Github 令牌,否则将不起作用。
    猜你喜欢
    • 1970-01-01
    • 2017-10-12
    • 2021-12-09
    • 2021-12-13
    • 2013-03-27
    • 2015-12-08
    • 2016-07-06
    • 2016-07-26
    • 1970-01-01
    相关资源
    最近更新 更多