如何修复解析go.mod模块,将其路径声明为"x".但要求以"y"表示 [英] How to fix parsing go.mod module declares its path as "x" but was required as "y"
问题描述
我正在研究一个go项目,该项目依赖于 original-project
.我现在想通过修改 original-project
来更改此项目中的行为.所以我将 github.com/y/original-project
克隆到 github.com/x/my-version
并替换了 github.com/y/带有
(包括在 github.com/x/my-version
的原始项目 mod.go
中).
I am working on a go project, which has a dependency on original-project
. I now want to change the behavior in this project by modifying original-project
. So I cloned github.com/y/original-project
to github.com/x/my-version
and replaced all occurrence of github.com/y/original-project
with github.com/x/my-version
(including in mod.go
).
但我一直收到此错误:
go: github.com/x/my-version@v0.5.2: parsing go.mod:
module declares its path as: github.com/y/original-project
but was required as: github.com/x/my-version
即使我运行 go get -u -v -f all
或 github.com/x/my-version
我做错了什么?
推荐答案
我遇到了类似的问题.我最终在试图导入的项目中删除了go.mod文件,并再次运行 go mod init ...
.它修复了它.
I had similar issue. I ended up removing the go.mod file in the project I was trying to import and running go mod init ...
again. It fixed it.
还要在要导入的地方运行 go clean -modcache
.
Also, run go clean -modcache
where you are importing.
然后尝试获取...
您的包裹.
这篇关于如何修复解析go.mod模块,将其路径声明为"x".但要求以"y"表示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!