I recently had to fork one of the packages that I was using in my golang project and it wasn’t so straight forward as you might think.
So heres the steps to make it work:
- Fork the package
- Make your changes and push them
go mod edit -replace github.com/original/gopackage=github.com/you/go-git@branch
for my example I had issues with package
So first I forked the project and then did my changes.
Then I run
go mod edit -replace github.com/google/go-github/v33=github.com/nocubicles/go-github/v33@fix
fix is the branch were the fix is located
And now my go.mod looks like this:
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/lib/pq v1.8.0 // indirect
replace github.com/google/go-github/v33 => github.com/nocubicles/go-github/v33 v33.0.1-0.20201216133612-dbf00b79615f