Reputation: 8331
I have a dependency library in go.mod
file, e.g. foo.bar/dep
. I want to patch only one package of this dependency, e.g. foo.bar/dep/pkg1
and place it somewhere in source repository, e.g. ./_patch/foo.bar/dep/pkg1
.
When I try to do this and replace it with
go mod edit -replace foo.bar/dep/pkg1=./_patch/foo.bar/dep/pkg1
go mod tidy
and my go.mod
looks like
require (
foo.bar/dep v1.0.0
)
replace foo.bar/dep/pkg1 => ./_patch/foo.bar/dep/pkg1
But when I build and run cmd, the code is still using origin foo.bar/dep/pkg1
module instead of my patch.
Is it possible to replace only some particular package of dependency, or the only way is to replace the whole library?
Upvotes: 1
Views: 3210
Reputation: 42431
Is it possible to replace only some particular package of dependency [?]
No.
[...] or the only way is to replace the whole [module]?
Yes, this is the only way.
Upvotes: 4