英文:
Keep 2 different minor versions of the same transitional dependency in Golang
问题
我有以下情况。我的项目有两个依赖项:
- example.com/a - 需要 example.com/c v0.1.0
- example.com/b - 需要 example.com/c v0.2.0
example.com/c 的开发人员在 0.2.0 版本中进行了一些不兼容的更改,导致 example.com/a 构建失败,但 example.com/b 依赖于 example.com/c 的开发人员在 0.2.0 版本中添加的新功能,所以我的项目无法同时编译 example.com/c v0.1.0 和 v0.2.0。
根据 Golang 文档,example.com/c 的开发人员有权进行不兼容的更改,因为他们尚未发布 v1.0.0 版本,所以他们在这里没有责任。
Golang 使用 example.com/c 的旧版本或新版本,但不能同时使用两个版本,因为它们的主要版本相同,这导致项目在任一版本下失败。
我无法访问 example.com/c 仓库,所以无法在这里修复问题,但我可以 fork 一个仓库并使用我的副本。
有哪些最小的操作可以让我在项目中同时使用这两个依赖项?
英文:
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?
答案1
得分: 1
你不能这样做。你必须“分叉”(即重命名)其中一个,并重新编写所有内容。
这里的教训是:不要依赖不稳定的东西。尤其是不要传递依赖。
英文:
> 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论