去上叉的github仓库,得到“意外的模块路径";错误 [英] go get on forked github repo got "unexpected module path" error
问题描述
我目前正在使用此仓库 https://github.com/awslabs/goformation来研究AWS Cloudformation. .因为我做了一些自定义,所以我做了一个 https://github.com/vrealzhou/goformation .
I'm currently working something on AWS Cloudformation which using this repo https://github.com/awslabs/goformation. Because I did some customise so I made a fork https://github.com/vrealzhou/goformation.
现在在我的其他项目中(使用go模块),我正在尝试使用go get github.com/vrealzhou/goformation@v2.3.1
,但出现此错误:
Now in my other project (using go module) I'm trying to using go get github.com/vrealzhou/goformation@v2.3.1
and I've got this error:
go: github.com/vrealzhou/goformation@v0.0.0-20190513073615-ff3b65adb278: parsing go.mod: unexpected module path "github.com/awslabs/goformation"
go: error loading module requirements
有人知道原因以及如何解决此问题吗?谢谢
Does anyone know the reason and how to solve this problem? Thanks
推荐答案
您可以在go.mod
中使用replace
来使用派生而不是上游版本.这样,您可以对代码进行任何需要的修改,而不必更新模块路径或导入路径.
You can use replace
in your go.mod
to use a fork instead of the upstream version. That way, you can make whatever modifications you need to the code without having to update the module path or import paths.
在这种情况下,具体来说,您可以在go.mod
中执行以下操作(我通过分叉存储库,进行了小的更改并确认显示了它来进行测试):
To be specific, in this case, you can do the following in your go.mod
(I tested this by forking the repo, making a small change, and confirming it showed up):
require github.com/awslabs/goformation v1.4.1
replace github.com/awslabs/goformation => github.com/vrealzhou/goformation master
第一次构建或测试时,master
将被fork的最新伪版本所代替,以确保获得可重复的构建. replace
需要用于替换的特定版本.
The first time you build or test, master
will be replaced by the latest pseudo-version for your fork to make sure you get repeatable builds. The replace
requires a specific version for the replacement.
这篇关于去上叉的github仓库,得到“意外的模块路径";错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!