简体   繁体   English

去上叉的github仓库得到“意外的模块路径”错误

[英]go get on forked github repo got “unexpected module path” error

I'm currently working something on AWS Cloudformation which using this repo https://github.com/awslabs/goformation . 我目前正在使用此仓库https://github.com/awslabs/goformation在AWS Cloudformation上工作。 Because I did some customise so I made a fork https://github.com/vrealzhou/goformation . 因为我做了一些自定义,所以我做了一个叉子https://github.com/vrealzhou/goformation

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模块),我尝试使用go get github.com/vrealzhou/goformation@v2.3.1 ,但出现了以下错误:

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 谢谢

You can use replace in your go.mod to use a fork instead of the upstream version. 您可以使用replacego.mod使用叉子,而不是上游版本。 That way, you can make whatever modifications you need to the code without having to update the module path or import paths. 这样,您可以对代码进行任何需要的修改,而不必更新模块路径或导入路径。

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): 具体来说,在这种情况下,您可以在go.mod执行以下go.mod (我通过分叉存储库,进行了小的更改并确认显示了它来进行测试):

require github.com/awslabs/goformation v1.4.1

replace github.com/awslabs/goformation => github.com/vrealzhou/goformation master

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. 首次构建或测试时, master将被最新的伪版本替换为fork,以确保获得可重复的构建。 The replace requires a specific version for the replacement. replace需要特定版本的替换。

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

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