Say my Go project depends on package example.com/foo
. I am using Go 1.12
, so the dependency is automatically pulled in by Go modules. The dependency seems to have a bug, so I want to add logs in the source code.
I can find the source code of on GitHub but I don't know how to make it as part of my project for debugging purposes.
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 -mod=vendor myapp.go