[英]When to upgrade go version in go.mod?
Typically a Go project will deal with 2 versions of Go:通常一个 Go 项目会处理 Go 的两个版本:
go.mod
go.mod
的最低版本I don't understand well when to upgrade the version in go.mod
vs when not to (if that is ever the case).我不太了解何时升级
go.mod
中的版本与何时不升级(如果是这种情况)。 For example, if I have a locally installed Go 1.16.9, does it make sense to set go 1.19
in the go.mod
file?例如,如果我本地安装了 Go 1.16.9,那么在
go.mod
文件中设置go 1.19
是否有意义? Should the go version in go.mod
be on par with the locally installed version of Go? go.mod
中的 go 版本是否应该与本地安装的 Go 版本相当? Can it be higher or lower?能高点还是低点?
Something that confuses me is the term minimum version of Go required by the current module
, ie is this similar to how Android has a minimum-compatibility version?令我感到困惑的是
minimum version of Go required by the current module
,即这与 Android 具有最低兼容版本的方式相似吗? Does a lower version in go.mod
mean the module can be installed on a wider range of machines and is this a good thing? go.mod
中的较低版本是否意味着该模块可以安装在更广泛的机器上,这是一件好事吗?
Ideally you want to use the lowest version you are comfortable with.理想情况下,您希望使用您熟悉的最低版本。
If a new standard library function is locked behind a new Go version, then you may decide its important to upgrade Go in order to use that function.如果新的标准库 function 被锁定在新的 Go 版本之后,那么您可能会决定升级 Go 以便使用该 function 很重要。
However you should respect that when you upgrade the Go version, you force that new version upon consumers of your module.但是,您应该尊重这一点,当您升级 Go 版本时,您会将新版本强加给模块的消费者。 You may not care about that, but if you do, then it makes sense to use the lowest version you can, in order to serve the largest audience.
您可能不关心这一点,但如果您关心,那么使用尽可能低的版本以服务于最大的受众是有意义的。
It depends.这取决于。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.