golang/go

Using `go mod tidy` on v1.21+ breaks usage of older Go mod

Closed this issue · 5 comments

What version of Go are you using (go version)?

v1.21.x

Does this issue reproduce with the latest release?

Use any v1.21 and then compare with any older version (of which many are supported).

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOOS='darwin'
GOARCH='arm64'

What did you do?

  • Using a Go 1.21 or newer call "go mod tidy"
  • Open this project on an earlier Go and call "go mod tidy" again

Command will fail to run

What did you expect to see?

Compatibility

What did you see instead?

go: errors parsing go.mod:
/Users/andy/Code/Fyne/fyne/go.mod:3: invalid go version '1.21.1': must match format 1.23

More

I do not know what can be done here, but this is taking the assertion that a metadata change does not impact the backwards compatibility promise to the extreme.
In one release a new format was introduced in a way that in the prior release it was impossible to use.

Can't we at least have a migration path so that people working on a team do not all have to upgrade at the same time?

In go1.21+ the go directive specifies the minimum version of go necessary to build the project, using a project with an older toolchain and newer go version requirement isn't supported.

Suggestion: Leave in support for x.y.z versions but roll back the forced move to these when module is updating until at least v1.22 (or 1.23 so we do not break mid-support-cycle).

In go1.21+ the go directive specifies the minimum version of go necessary to build the project, using a project with an older toolchain and newer go version requirement isn't supported.

I appreciate that there is a reason for this change, however it does lead to situations where go.mod can have "go 1.20.4" in the header and a 1.20 compiler can no longer read the project.

Surely if the "go mod tidy" was doing a complete job of maintaining the compatibility it would see the < 1.21 and trim the .z from the end to ensure compatibility with the version stated?

Can you please re-open so we can address the above backwards-incompatibility...

There cannot be go1.20.4, it's not a valid version, and it wouldn't be safe for go to change something it doesn't know about.
Compatibility with older versions during tidy is done using the -go flag