Go模块在今天是否真的可用,考虑到第三方的“不兼容”模块?

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

Are Go modules really usable today given third party "incompatible" modules?

问题

我是新手,正在尝试创建我的第一个Go程序。按照各种入门教程,我创建了一个新模块,但是为了我的目的,这个模块需要依赖于另一个模块:

github.com/timescale/promscale@0.6.2

我的问题是,这个模块有一些依赖没有“正确采用”语义化版本控制的方法。

go list -e -m all
...
k8s.io/client-go v12.0.0+incompatible
...

报告了37个这样的模块...所以联系模块的作者让他们采用SIV,就像我看到的建议那样,可能不是一个选项。

我是不是漏掉了什么,或者我应该完全放弃在这个新项目中使用模块?

英文:

I am new to Go and trying to create my first program. Following the various getting started & tutorials I create a new module, which for my purpose needs to have a dependency on this module:

github.com/timescale/promscale@0.6.2

My problem is that the module has dependencies that have not "properly adopted" the semantic versioning approach.

go list -e -m all
...
k8s.io/client-go v12.0.0+incompatible
...

reports 37 such modules... so contacting the module author to have them adopt SIV, as I have seen suggested, will not be an option.

Am I missing something, or should I simply completely give up on using modules for this new project?

答案1

得分: 2

你好!以下是翻译好的内容:

> 鉴于第三方“不兼容”的模块,Go模块今天真的可用吗?

是的。

> 我有什么遗漏吗?

也许:这个“+incompatible”并不意味着失败。

> 或者我应该完全放弃在这个新项目中使用模块吗?

不,当然不需要完全放弃。

英文:

> Are Go modules really usable today given third party "incompatible" modules?

Yes.

> Am I missing something

Maybe: This "+incompabtible" is not a sign of failure.

> or should I simply completely give up on using modules for this new project?

No, of course not.

答案2

得分: 0

感谢您的答案和评论,看起来:

  1. 新项目应该使用模块,+不兼容的依赖关系会出现,但这没关系。

  2. 这个FAQ条目是正确的,只需阅读前两行,将“Additional Details”留到以后。

  3. 如果存在+不兼容的依赖关系,go list -m all不会像所有教程中描述的那样工作,它会在第一个不兼容的模块上出错。

go list -m -e all似乎按预期工作。

如果您使用Goland,使用GOFLAGS=-e似乎可以使依赖关系解析正常工作,尽管存在+不兼容的模块。这可能会产生我不知道的副作用。

英文:

Thanks for the answers and comments, it seems that:

  1. New project should use modules, +incompatible dependencies will come up but that is fine

  2. This FAQ entry has it right, just read the first 2 lines and keep "Additional Details" for a rainy day

  3. go list -m all won't behave as described in all the tutorials if +incompatible dependencies exist, it will choke on the first incompatible module instead.

go list -m -e all seems to work as expected.

If you are using Goland, using GOFLAGS=-e seems to make dependency resolution work despite +incompatible modules. This may well have side effects that I am not aware of.

huangapple
  • 本文由 发表于 2021年11月26日 00:52:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/70114796.html
匿名

发表评论

匿名网友

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

确定