setup-go-faster
setup-go-faster copied to clipboard
add option to make Go version from go.mod exact
I really like this action overall and have currently switched to using it instead of actions/setup-go. However, one behavioral difference surprised me.
Since Go 1.21.0 released I have been using the go directive in my go.mod files to pin the version of Go that will be used locally and in Actions workflows. I originally used the go-version-file option of actions/setup-go and when switching to using setup-go-faster was pleased to see the option was here was well. I was not expecting the version in go.mod to be used as a minimum version though, but was an exact(ish) version (Go 1.21.0+ can handle full versions but earlier toolchains can't as you know).
My proposal is to add an option to optionally strictly match the version declared in go.mod when go-version-file is also passed. If a Go version less than 1.21.0 is passed or a version greater or equal to 1.21 was passed without specifying the patch version, the major and minor versions would be matched exactly but the latest patch version would be used. Otherwise the exact version would be loaded. Obviously this option would not be enabled by default to avoid breaking backwards compatibility.
I like this idea, but I want a better understanding of the toolchain changes in 1.21 before moving forward. I've been reading https://go.dev/doc/toolchain trying to understand this brave new world.
From what I've read so far, it seems like it would make sense to use the toolchain directive here instead of just the go directive. Essentially setup-go-faster should ask what toolchain go would use if running in the same directory as this go.mod file, then install that version. Does that seem right to you?
Yes and no; I think supporting the toolchain directive is a different issue than this one, though I would like that supported as well. I think the logic should be as simple as:
- Get version from
go - Get version from
toolchain - Use the greater version between the two
As for using an exact version, the toolchain directive seems to be similar to the go directive in that it specifies the minimum Go toolchain version, not an exact one. So my request would be roughly the same: whatever is the greater version between the go and toolchain directives, install that version exactly when a new option is set.