4 ms·
The replace directive does allow you to use a different import path, not just a local path. Unless there's something I'm missing about your use case? https://g
by xyzzy_plugh 5y ago
The replace directive does allow you to use a different import path, not just a local path. Unless there's something I'm missing about your use case?
https://golang.org/ref/mod#go-mod-file-replace https://golang.org/ref/mod#go-mod-file-replace
- harikb 5y agoOh I never knew! Thanks. That does simplify a lot
- tsimionescu 5y agoIt's important to note that it still doesn't apply to downstream users (those adding your package to their go.mod), only to those building your package directly. I think this decision makes sense, so this is not a complaint.
- caust1c 5y agoCan you elaborate? We use `replace` everywhere in our codebase for modules that we've forked + modified.
- tsimionescu 5y agoAssume module A depends on module B, and module B has a dependency on module github.com/C, and a replace rule for github.com/C => company.internal/C. When you build module A, it will pull module B and module github.com/C, instead of B and company.internal/C, unless A has its own replace directive for C.