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

relax go version? #1042

Closed
jharley opened this issue Sep 19, 2024 · 2 comments
Closed

relax go version? #1042

jharley opened this issue Sep 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@jharley
Copy link

jharley commented Sep 19, 2024

With the recent release of v1.12.0, "go.mod"'s go directive was changed to go 1.22.0. This has a knock-on effect of requiring any project update their directive to at least that (with the patch) as well.

My understanding is that the go directive is used to specify the language semantics in use in the project, while the toolchain directive can be used to specify an exact toolchain version requirement. I think it'd be ideal to update to go 1.22 (no patch) for semantics but something like toolchain go1.22.7.

n.b. there are a number of other Terraform-related libraries that had a similar change made to include the patch version in the go directive, but I thought I'd start with this one issue. :)

@jharley jharley added the bug Something isn't working label Sep 19, 2024
@austinvalle
Copy link
Member

austinvalle commented Sep 19, 2024

Hey there @jharley 👋🏻, trying to dig through Go's documentation and some GH issues to make sure we get the right go.mod directive 😆, lots of discussion around this area lol.


Interestingly enough, I wasn't able to generate go 1.22 with the toolchain operations go get (it always added the patch version I'm using 1.22.7, I explicitly chose to use go get go@1.22.0 to make sure we didn't enforce a specific patch version), but I can get a go directive of 1.22 using the old style go mod edit.

There is a long thread on a semi-related bug that I believe doesn't exist anymore that has some interesting info: golang/go#62278. Specifically this comment summarizes what I believe is current state, which is that the Go tooling now wants our modules to specify the release language version, of which 1.22.0 is valid and 1.22 is a development version.

It looks like the Go team has since adjusted their tooling to be more lenient and "assume the lack of patch version == .0", but I believe the expectation (another comment discussing this) is still to specify the minimum release language versions, so 1.22.0 should be the correct setup for the terraform-plugin-framework module.


From your experience upgrading, did you run into that "toolchain not available" error message? And then a follow up go mod tidy added the minimum required version plus the toolchain? We don't want to cause unnecessary strife while upgrading, but we also want to follow the semantics enforced by the Go tooling.

@jharley
Copy link
Author

jharley commented Sep 19, 2024

Thanks for the speedy response and the links: this is one of those "everything I thought I knew is wrong" moments 😅

I'll adjust my project accordingly and we'll for sure be socializing this internally.

@jharley jharley closed this as completed Sep 19, 2024
jharley added a commit to honeycombio/terraform-provider-honeycombio that referenced this issue Sep 19, 2024
#545 required an update to "go.mod" such that the `go` directive went
from `1.22` to `1.22.0` in order to appease the compiler.

This was confusing to me, so I opened
hashicorp/terraform-plugin-framework#1042 and
learned that things had ✨ changed ✨.

Looking at the [Go documentation](https://go.dev/doc/toolchain#get) we
should be using `go get go@1.X` when upgrading Go versions, and because
the current `toolchain` directive value will match it is excluded.

For example, the change set in this PR is from running:

```
$ go get go@1.22
go: upgraded go 1.22.0 => 1.22.7
go: removed toolchain go1.22.7
```
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants