1

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?

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.