简体   繁体   English

使用 Go 依赖项的修改版本时出现问题

[英]Issue with using a modified version of a Go dependency

So here is the situation:所以情况如下:

I have a fork of go-ipfs .我有一个go-ipfs It depends on go-ipfs-config .这取决于go-ipfs-config I need to modify go-ipfs-config and make go-ipfs depend on my modified version.我需要修改go-ipfs-config并使go-ipfs依赖于我修改后的版本。

I forked the go-ipfs-config made my changes and made sure to update the path to be that of my forked version as can be seen here .我分叉了go-ipfs-config进行了更改,并确保将路径更新为我的分叉版本的路径,如此处所示 I confirmed that this still builds successfully by running go build我通过运行go build确认这仍然可以成功构建

Then I updated go.mod in go-ipfs to use my modified version.然后我更新了go-ipfs go.mod的 go.mod 以使用我的修改版本。 I used the replace directive to signify this intention which can be seen here我使用replace指令来表示这个意图,可以在这里看到

This is where things gets absolutely bunkers and I am no longer sure what is going on.这就是事情变得绝对掩体的地方,我不再确定发生了什么。

When i do go mod tidy to fetch the dependency i get the following output:当我做go mod tidy以获取依赖项时,我得到以下 output:

go: finding module for package github.com/dadepo/go-ipfs-config
go: found github.com/dadepo/go-ipfs-config in github.com/dadepo/go-ipfs-config v0.5.3

The crazy thing is that v0.5.3 does not exist in github.com/dadepo/go-ipfs-config!疯狂的是, v0.5.3中不存在 v0.5.3!

Also the following line get added to go.mod:还将以下行添加到 go.mod 中:

github.com/dadepo/go-ipfs-config v0.5.3 // indirect

Which can even be seen here甚至可以在这里看到

I have run commands like go clean -modcache and go clean -r etc but does not seem to fix things!我已经运行go clean -modcachego clean -r等命令,但似乎没有解决问题!

Does anybody know what I am doing wrong?有人知道我做错了什么吗? And also how to achieve the goal of making my version of a project depend on another modified version of its dependency?以及如何实现使我的项目版本依赖于其依赖项的另一个修改版本的目标?

Ok, so this is as a result of me not being aware of couple of things going on in the Go lang toolchain.好的,这是因为我没有意识到 Go lang 工具链中发生的一些事情。

Apparently https://proxy.golang.org is a thing.显然https://proxy.golang.org是一回事。 It is a service operated by google that caches modules, So If you made a release, deleted it, chances are that the version is already cached in https://proxy.golang.org .它是 google 运营的缓存模块的服务,所以如果你发布了,删除它,很可能该版本已经缓存在https://proxy.golang.org中。 This was exactly what happened in my case.这正是我的情况。 I had made a 0.5.3 release, deleted it, but it is not really gone as the Google cache already got a hold of it.我发布了 0.5.3 版本,删除了它,但它并没有真正消失,因为 Google 缓存已经掌握了它。

So in case you are seeing versions that should not exist.因此,如果您看到不应该存在的版本。 This should be the first place you check.这应该是您检查的第一个地方。 This documentation link also sheds some more light on the proxy and how it can be tweaked.文档链接还对代理以及如何调整它提供了更多信息。

I found this out based on the conversation I had on the issue I opened reporting this behaviour.我是根据我在打开报告此行为的问题上进行的对话发现的。 If you are curious, you can check it out here .如果您好奇,可以在这里查看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM