Search code examples
godependencies

Keep 2 different minor versions of the same transitional dependency in Golang


So I have the following situation. I have 2 dependencies on my project:

  • example.com/a - requires example.com/c v0.1.0
  • example.com/b - requires example.com/c v0.2.0

The devs of example.com/c made some backwards incompatible changes in 0.2.0, causing example.com/a building to fail, but example.com/b relies on new features that example.com/c’s devs added in 0.2.0, so my project fails to compile with both example.com/c v0.1.0 and v0.2.0

The devs of example.com/c, according to golang documentation, have every right to make backwards incompatible changes, given that they didn’t release v1.0.0 yet, so they are not to blame here.

Golang uses either old or new version of example.com/c, but not both of them together, as their major version is the same, causing the project to fail with either of these.

I don’t have access to example.com/c repo so I cannot fix things here, but I can fork a repo and use my copy of it.

What are the minimal actions that could be taken so I can use both of the dependencies in my project in parallel?


Solution

  • What are the minimal actions that could be taken so I can use both of the dependencies in my project in parallel?

    You cannot. You have to "fork" (i.e. rename) one and rewrite everything.

    The lesson here is: Do not rely on unstable stuff. Especially not transitively.