登录
首页 >  Golang >  Go问答

私人仓库 - go 1.13 - 在运行`go mod ..`时出错:无法连接到 "sum.golang.org/lookup" 进行验证,返回错误码410

来源:stackoverflow

时间:2024-03-04 19:03:27 137浏览 收藏

编程并不是一个机械性的工作,而是需要有思考,有创新的工作,语法是固定的,但解决问题的思路则是依靠人的思维,这就需要我们坚持学习和更新自己的知识。今天golang学习网就整理分享《私人仓库 - go 1.13 - 在运行`go mod ..`时出错:无法连接到 "sum.golang.org/lookup" 进行验证,返回错误码410》,文章讲解的知识点主要包括,如果你对Golang方面的知识点感兴趣,就不要错过golang学习网,在这可以对大家的知识积累有所帮助,助力开发能力的提升。

问题内容

我正在使用 golang 1.13 。

我有一个项目依赖于私人 gitlab 项目。

我有相同的 ssh 密钥。

当我尝试检索新创建的模块的依赖项时,出现以下错误:

$ go version
go version go1.13 linux/amd64

$ go mod why
go: downloading gitlab.com/mycompany/myproject v0.0.145
verifying gitlab.com/mycompany/[email protected]: gitlab.com/mycompany/[email protected]: reading https://sum.golang.org/lookup/gitlab.com/mycompany/[email protected]: 410 gone

我不知道为什么它要尝试 ping sum.golang.org/lookup,因为它是一个私人 gitlab 项目。

我的 ~/.gitconfig 包含以下内容(基于我在谷歌搜索中查找类似错误)

# Enforce SSH
[url "ssh://[email protected]/"]
  insteadOf = https://github.com/
[url "ssh://[email protected]/"]
        insteadOf = https://gitlab.com/
[url "ssh://[email protected]/"]
  insteadOf = https://bitbucket.org/
[url "[email protected]:"]
        insteadOf = https://gitlab.com/

错误仍然存​​在。

我希望将包从我的私人 gitlab 项目存储库下载到当前项目。

我需要在我的私人 gitlab 项目存储库中做些什么才能使其为“go get”做好准备吗?

私有 gitlab 项目存储库也已经包含该项目的 go.sum 和 go.mod。

我缺少什么吗?

编辑:1)私有仓库名称和公司名称不包含星号或任何其他特殊字符。只有字母,甚至没有数字字符。


解决方案


查找后回答我自己的问题,

设置 goprivate 变量似乎有帮助。

goprivate=gitlab.com/mycompany/*  go mod why

” 新的 goprivate 环境变量指示不公开可用的模块路径。它用作较低级别 gonoproxy 和 gonosumdb 变量的默认值,这些变量提供对通过代理获取哪些模块并使用校验和数据库进行验证的更细粒度的控制。 “来自 https://golang.org/doc/go1.13

阿利特:

设置环境变量 gonosumdb 似乎也有效。 具体来说,调用以下命令似乎有帮助。

gonosumdb=gitlab.com/mycompany/* go mod why

上述环境变量阻止对 sum.golang.org/lookup 执行 ping 操作以获取校验和匹配。它还可以防止将私有存储库的名称泄漏到公共校验和数据库。 [来源 - https://docs.gomods.io/configuration/sumdb/]

另外 - 这里

* GONOSUMDB=prefix1,prefix2,prefix3 sets a list of module path prefixes, again possibly containing globs, that should not be looked up using the database.

来源:https://go.googlesource.com/proposal/+/master/design/25530-sumdb.md

相关问题:

好了,本文到此结束,带大家了解了《私人仓库 - go 1.13 - 在运行`go mod ..`时出错:无法连接到 "sum.golang.org/lookup" 进行验证,返回错误码410》,希望本文对你有所帮助!关注golang学习网公众号,给大家分享更多Golang知识!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>