This one related to #520, in which it turns out that our Go 1.21 build
step has actually been automatically upgrading itself to Go 1.22, so
under the radar that we didn't notice.
Here, leverage a Go "toolchain" to establish a preferred version of Go
for the project, but keeping a go directive in go.mods that's at the
1.21 lower bound that we're trying to support. The presence of a
toolchain directive prevents go mod tidy from upgrading the go
directive to the latest version of Go installed.
I found the easiest way to add the toolchain directive to be with go get [2] like:
go get go@1.21 toolchain@1.22.5
Maintaining this correctly is going to be a little tricky. This is one
of those classic Go features that kind of works, but various Go commands
will perform all kinds of confusing behavior like stripping directives
out of your file if there's anything even a tiny bit wrong, and with no
explanation whatsoever.
I found that to get this working I had to started with the "inner"
dependencies like rivershared and rivertype, go get Go/toolchain
there first, then work my way up the stack all the way up to the main
project.
I'm going to try and follow this up with some tooling to help make this
easier for ourselves, and a build check that verifies in CI that nothing
gets accidentally regressed as we make changes because this is very
easy to do accidentally.
This one related to #520, in which it turns out that our Go 1.21 build step has actually been automatically upgrading itself to Go 1.22, so under the radar that we didn't notice.
Here, leverage a Go "toolchain" to establish a preferred version of Go for the project, but keeping a
go
directive ingo.mod
s that's at the 1.21 lower bound that we're trying to support. The presence of atoolchain
directive preventsgo mod tidy
from upgrading thego
directive to the latest version of Go installed.I found the easiest way to add the toolchain directive to be with
go get
[2] like:Maintaining this correctly is going to be a little tricky. This is one of those classic Go features that kind of works, but various Go commands will perform all kinds of confusing behavior like stripping directives out of your file if there's anything even a tiny bit wrong, and with no explanation whatsoever.
I found that to get this working I had to started with the "inner" dependencies like
rivershared
andrivertype
,go get
Go/toolchain there first, then work my way up the stack all the way up to the main project.I'm going to try and follow this up with some tooling to help make this easier for ourselves, and a build check that verifies in CI that nothing gets accidentally regressed as we make changes because this is very easy to do accidentally.
Fixes #520.
[1] https://go.dev/doc/toolchain [2] https://go.dev/doc/toolchain#get