Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to make Go version from go.mod exact #26

Open
capnspacehook opened this issue Sep 22, 2023 · 2 comments
Open

add option to make Go version from go.mod exact #26

capnspacehook opened this issue Sep 22, 2023 · 2 comments

Comments

@capnspacehook
Copy link

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.

@WillAbides
Copy link
Owner

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?

@capnspacehook
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants