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

假如想象 提交于 2020-06-22 19:45:12

问题


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.

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


回答1:


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.

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

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.



来源:https://stackoverflow.com/questions/56122066/go-get-on-forked-github-repo-got-unexpected-module-path-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!