使用两要素认证的“ go get”私有github存储库

问题描述

我们的私有组织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 for non-public modules并将Github帐户作为值来实现了这一目标。

并通过配置代理以获取directly

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

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

相关问答

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