在Golang中保留两个不同的次要版本的相同过渡依赖

huangapple go评论80阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2021年12月7日 00:53:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/70249022.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定