hashicorp / terraform-plugin-framework

A next-generation framework for building Terraform providers.
https://developer.hashicorp.com/terraform/plugin/framework
Mozilla Public License 2.0
297 stars 91 forks source link

relax go version? #1042

Closed jharley closed 6 days ago

jharley commented 6 days ago

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 toolchaindirective 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. :)

austinvalle commented 6 days ago

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: https://github.com/golang/go/issues/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 commented 6 days ago

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.