问题描述
我们的私有组织GitHub帐户通过
进行了身份验证-
双重身份验证
-
个人访问令牌
当我尝试通过私有组织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/