首页 > 解决方案 > “go get”无法下载 go 包,托管在 Github Entreprise 上的 git 存储库(在 VPN 之后)

问题描述

我正在尝试下载 Entreprise Github 上的 Go 包。

值得注意的是,该域在 VPN 之外不可见,但我已连接到该 VPN。

我可以https://github.mydomain.com/some_repository用浏览器浏览,但是我需要登录。

$ go get -v github.mydomain.com/some_repository

get "github.mydomain.com/some_repository": found meta tag get.metaImport{Prefix:"github.mydomain.com/some_repository", VCS:"git", RepoRoot:"https://github.mydomain.com/some_repository.git"} at //github.mydomain.com/some_repository?go-get=1
go: downloading github.mydomain.com/some_repository v0.0.0
go get github.mydomain.com/some_repository: github.mydomain.com/some_repository@v0.0.0: verifying module: github.mydomain.com/some_repository@v0.0.0: reading https://sum.golang.org/lookup/github.mydomain.com/some_repository@v0.0.0: 410 Gone
        server response: not found: github.mydomain.com/some_repository@v0.0.0: unrecognized import path "github.mydomain.com/some_repository": https fetch: Get "https://github.mydomain.com/some_repository?go-get=1": dial tcp: lookup github.mydomain.com on 8.8.8.8:53: no such host

我最初认为这是由于命令行工具没有访问令牌,因为浏览器可以访问但不能访问go get. 我在 Entreprise Github 上生成了一个令牌,并尝试通过以下方式解决此问题:

git config --local http.extraheader "PRIVATE-TOKEN: <token>"
git config --local url."git@github.mydomain.com:".insteadOf "https://github.mydomain.com/"

正如这里所解释的,但这并没有帮助。

的存在lookup github.mydomain.com on 8.8.8.8:53: no such host可能是一个线索,因为 8.8.8.8 是 google 的 DNS,并且由于 mydomain.com 仅存在于 VPN 上,所以这不可能工作。如果与 VPN 断开连接,则表明 mydomain.com 不存在。我不确定为什么go get会使用 8.8.8.8 作为 DNS。

scutil --dns | grep 'nameserver\[[0-9]*\]'列出了几个 DNS 服务器,其中没有一个是 8.8.8.8,所以也许是go get硬编码的?

标签: gitgogithubgithub-enterprise

解决方案


看来设置环境变量GOPRIVATE=*.mydomain.com可以解决这个问题。


推荐阅读