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
- run
go mod edit -replace github.com/original/gopackage=github.com/you/go-git@branch
for my example I had issues with package github.com/google/go-github
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
where the fix
is the branch were the fix is located
And now my go.mod looks like this:
module github.com/nocubicles/skillbase.io
go 1.15
require (
github.com/aws/aws-sdk-go v1.35.33
github.com/gofrs/uuid v3.2.0+incompatible
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-github/v33 v33.0.0
github.com/gorilla/mux v1.8.0
github.com/jinzhu/gorm v1.9.16
github.com/joho/godotenv v1.3.0
github.com/lib/pq v1.8.0 // indirect
golang.org/x/oauth2 v0.0.0-20201203001011-0b49973bad19
gorm.io/driver/postgres v1.0.5
gorm.io/gorm v1.20.8
)
replace github.com/google/go-github/v33 => github.com/nocubicles/go-github/v33 v33.0.1-0.20201216133612-dbf00b79615f