I have a dependency library in go.mod
file, eg foo.bar/dep
. I want to patch only one package of this dependency, eg foo.bar/dep/pkg1
and place it somewhere in source repository, eg ./_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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.