Typically a Go project will deal with 2 versions of Go:
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). 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? Should the go version in go.mod
be on par with the locally installed version of 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? 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?
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.
However you should respect that when you upgrade the Go version, you force that new version upon consumers of your module. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.