How to make sure consistent versioning with replace directive in go.mod?

I have a very specific setup for a few internal Go packages at work, where maintaining the versions is not very ideal.

Let me try to explain the setup first.

package abc.com/A: v0.0.20

package abc.com/B: v0.0.10 depends on package A (package A is vendored)
package abc.com/C: v0.0.5 depends on package A (package A is vendored)

All these 3 packages are hosted on an internal Github instance say github1.abc.com, so anyone that needs to import this package needs a replace directive in their go.mod file.

So let’s say there’s an app X that needs to import B and C.

So the go.mod file for app X looks something like:

require (
    abc.com/B v0.0.10
    abc.com/C v0.0.5
)

replace abc.com/B => github1.abc.com/B v0.0.10
replace abc.com/C => github1.abc.com/C v0.0.5
replace abc.com/A => github1.abc.com/A v0.0.20

Without the last replace directive for package A, build for the app X doesn’t go through because app X also needs to know where A should come from even though A is vendored in both B and C.

Another problem is that app X needs to know the version of A that’s used by B and C and use that version number in the replace directive.

How do I make this setup more intuitive such that app X only has to bump the version numbers of its direct dependencies B, and C and not have to worry about A’s version number or a replace directive for A?

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.