Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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/[email protected] and I've got this error:

go: github.com/vrealzhou/[email protected]: 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

like image 388
vreal Avatar asked May 14 '19 02:05

vreal


People also ask

How do I open a forked repository in GitHub?

You can fork any repo by clicking the fork button in the upper right hand corner of a repo page. Click on the Fork button to fork any repo on github.com.

How do I find my forked repository on GitHub?

Clicking the number of forks shows you the full network. From there you can click "members" to see who forked the repo.

What happens if forked repo is deleted?

When you delete a public repository, one of the existing public forks is chosen to be the new parent repository. All other repositories are forked off of this new parent and subsequent pull requests go to this new parent.


1 Answers

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.

like image 109
Tyler Bui-Palsulich Avatar answered Oct 04 '22 22:10

Tyler Bui-Palsulich