找到模块但不包含包
我对 Go 存在依赖性问题,并试图了解根本原因,希望有人能提供一些线索。
我使用 Prometheus go 客户端( https://github.com/prometheus/client_golang )作为我的 Go 项目中的依赖项。它有一个称为 xxhash 的传递依赖项,Go 的模块感知版本可以通过 github.com/cespare/xxhash/v2 的虚拟路径发现该依赖项。看起来这个实用程序最近更新为使用 go 模块,这由它的 v2 后缀表示。
我在模块模式下运行 go 1.17.7 并使用默认的 GoPath。当我尝试运行 go mod tidy 时,它返回以下错误。
github.com/cespare/xxhash/v2: module github.com/cespare/xxhash/v2@latest found (v2.1.2), but does not contain package github.com/cespare/xxhash/v2
我正在模块模式下运行,这是一个传递依赖项,所以我希望 go 会在 $GOPATH\pkg\mod\cache\download\github.com\cespare\xxhash\v2\@v$GOPATH\pkg\mod\cache\download\github.com\cespare\xxhash\v2\@v 找到该版本。我确实看到该版本缓存在该精确文件夹中。然而,我还注意到 go 在 $GOPATH\pkg\mod\github.com\cespare\xxhash\[电子邮件受保护]
但来源尚未确定下载了。
我读过其他线程,其中通过升级到模块感知的较新版本的 Go 解决了这个问题,或者升级 Prometheus 客户端的版本,但在这种情况下,我为每个线程提供了最新版本。
I have a dependency issue with Go and was trying to understand the root cause, hopefully someone can shed some light.
I'm using the Prometheus go client ( https://github.com/prometheus/client_golang ) as a dependency in my Go project. This has a transitive dependency called xxhash, which is discoverable by module aware versions of Go through the virtual path of github.com/cespare/xxhash/v2. It looks like this utility was recently updated to use go modules and this is indicated by its v2 suffix.
I'm running go 1.17.7 in module mode and using the default GoPath. When I try to run go mod tidy it returns the following error.
github.com/cespare/xxhash/v2: module github.com/cespare/xxhash/v2@latest found (v2.1.2), but does not contain package github.com/cespare/xxhash/v2
I'm running in module mode and this is a transitive dependency so I expect that go will look in $GOPATH\pkg\mod\cache\download\github.com\cespare\xxhash\v2\@v
to find that version. I do see that version cached in that precise folder. I also notice however that go creates a directory for the same dependency at $GOPATH\pkg\mod\github.com\cespare\xxhash\[email protected]
but the source has not been downloaded.
I've read other threads where this was resolved by upgrading to a newer version of Go which was module aware , or alternatively upgrading the version of the Prometheus client however in this case I'm on the latest for each.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最初的 GOPATH 配置使用 Artifactory 形式的镜像代理来进行依赖关系解析。校验和冲突阻止拉入所有依赖项。我恢复到 proxy.golang.org 来解决该问题
The original GOPATH configuration was using a mirror proxy, in the form of Artifactory, for dependency resolution. Checksum collisions prevented pulling in all dependencies. I reverted to proxy.golang.org to resolve the issue