私人仓库-Go 1.13-`go mod ..`失败:ping"sum.golang.org/lookup" ..验证包.. 410不见了 [英] private repo - go 1.13 - `go mod ..` failed: ping "sum.golang.org/lookup" .. verifying package .. 410 gone

查看:134
本文介绍了私人仓库-Go 1.13-`go mod ..`失败:ping"sum.golang.org/lookup" ..验证包.. 410不见了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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/myproject@v0.0.145: gitlab.com/mycompany/myproject@v0.0.145: reading https://sum.golang.org/lookup/gitlab.com/mycompany/myproject@v0.0.145: 410 Gone

我不知道为什么要尝试对sum.golang.org/lookup进行ping操作,因为它是一个私有gitlab项目.

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

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

错误仍然存​​在.

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

我是否需要在我的私人gitlab项目存储库中做任何事情以使其准备好开始使用"?

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

我想念什么吗?

edit:1)私人存储库名称和公司名称不包含星号或任何其他特殊字符.仅字母,甚至不包括数字字符.

解决方案

抬起头来回答我自己的问题,

设置GOPRIVATE变量似乎有帮助.

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

" 新的GOPRIVATE环境变量指示了不可公开获得的模块路径.它用作较低级别的GONOPROXY和GONOSUMDB变量的默认值,它们对通过代理获取并使用校验和数据库进行验证的模块提供了更细粒度的控制. 来自<​​a href="https://golang.org/doc/go1.13" rel="noreferrer"> https://golang.org/doc/go1.13

升力:

设置环境变量GONOSUMDB似乎也可以. 具体来说,调用以下命令似乎有帮助.

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

上面的env变量阻止ping到sum.golang.org/lookup以进行校验和匹配.它还可以防止将私有存储库的名称泄露给公共校验和数据库. [来源- 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

相关问题:

I am using golang 1.13 .

I have a project that depends on a private gitlab project.

I have the ssh keys for the same.

When I try to retrieve the dependencies for a newly created module, I am getting the following error:

$ go version
go version go1.13 linux/amd64

$ go mod why
go: downloading gitlab.com/mycompany/myproject v0.0.145
verifying gitlab.com/mycompany/myproject@v0.0.145: gitlab.com/mycompany/myproject@v0.0.145: reading https://sum.golang.org/lookup/gitlab.com/mycompany/myproject@v0.0.145: 410 Gone

I have no idea why it is trying to ping sum.golang.org/lookup since it is a private gitlab project.

My ~/.gitconfig contains the following (based on my looking up in google search for similar errors)

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

The error still persists.

I would expect the package to be downloaded from my private gitlab project repository to the current project.

Is there anything I need to do in my private gitlab project repository to make it ready for 'go get' ?

The private gitlab project repository already contains the go.sum and go.mod for the project as well.

Anything that I am missing ?

edit: 1) The private repo name and the company name contains no asterisks or any other special characters. only alphabets and not even numeric characters.

解决方案

Answering my own question after looking up,

Setting the GOPRIVATE variable seems to help.

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

" The new GOPRIVATE environment variable indicates module paths that are not publicly available. It serves as the default value for the lower-level GONOPROXY and GONOSUMDB variables, which provide finer-grained control over which modules are fetched via proxy and verified using the checksum database. " from https://golang.org/doc/go1.13

Aliter:

Setting the env variable GONOSUMDB also seems to work. Specifically, invoking the following command seems to help.

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

The above env variable prevents the ping to sum.golang.org/lookup for a checksum match. It also prevents leaking the names of private repos to a public checksum db. [ Source - https://docs.gomods.io/configuration/sumdb/ ]

Also - here at

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

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

Related Issues:

这篇关于私人仓库-Go 1.13-`go mod ..`失败:ping"sum.golang.org/lookup" ..验证包.. 410不见了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆