nbio/xml

Why require 1.21.1?

Closed this issue · 5 comments

Hey, wondering why the go.mod of this module require that specific patch of golang. Does just an 1.21 not work?

Asking because this causes some repo maintenance troubles where go insists on setting up the toolchain directive because of the patch req.

Go 1.21 is no longer a valid version, but 1.21.0 is. See https://golang.org/doc/toolchain#version

There have been many patch releases with important fixes since 1.21.0: https://go.dev/doc/devel/release#go1.21.minor

But the go directive specifies minimum go version the package supports, see https://go.dev/ref/mod#go-mod-file-go, usually by supported feature set, e.g. things like https://pkg.go.dev/log/slog@master being only available in 1.21+. A go.mod file min go requirement that stops only at a minor, e.g. 1.21 is perfectly valid.

Go patches are usually security patches / such, rare to run into a package that legitimately doesn't function on a lower patch version under the same minor.

For recommendations of go compiler versions to use / similar it's possible to use the toolchain directive, see https://go.dev/ref/mod#go-mod-file-toolchain

Projects like perkeep do this, see https://github.com/perkeep/perkeep/blob/master/go.mod where it has a min go version of 1.21 and toolchain recommendation of 1.21.4

The reason I care is that... We use this fork of xml, and it's forcing some toolchain directives into go.mod files that are unnecessary because of the inclusion of the patch version on the go.mod min go requirement 😆

Got it. We can look into relaxing it. Have you tried out changing it, and does the change to 1.21 solve your problem? Maybe you can submit a PR that works for you?

If you haven't tried, go.work is probably the easiest way to vet the proposed change. e.g.

$ go work init
$ go work use
$ (cd ../.. && git clone https://github.com/nbio/xml)
$ go work use ../../nbio/xml

Hey, yep, I'm happy to PR.

Thanks. We'll have to review in our own workflows before merging.