How do I debug a dependency package? If I have its source code
First fetch all the dependency packages into the vendor
folder.
go mod vendor
Then, change the source code in that and build your project by specifying to look into vendor
folder.
go build -mod=vendor
or
go run -mode=vendor myapp.go
You can use replace directive:
replace example.com/original/import/path => /your/forked/import/path
Go module fetches packages into $GOPATH/pkg/mod
you can change the source code there or using the vendor option of go mod to pull the packages into vendor folder and then start coding there.