go-playground / validator

:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
MIT License
16.07k stars 1.29k forks source link

Bumping go version to 1.21 #1225

Closed ddymko closed 4 months ago

ddymko commented 4 months ago

Package version eg. v9, v10:

v1.10

Issue, Question or Enhancement:

Hey there 👋

Curious to see if there is a reason why the go version in go.mod is still on 1.18?

The go versions in other spots of the repo, mainly github actions, are on 1.21. If this was an oversight I'll gladly push up a PR to bump the version 🙂 !

deankarn commented 4 months ago

@ddymko this was not an oversight and changing it would be a breaking change.

  1. The GitHub Actions are not limited to Go 1.18, in fact at the time of writing test run using Go 1.17 through Go 1.21.
  2. The go directive is the minimum version supported and states:
    The go directive sets the minimum version of Go required to use this module. Before Go 1.21, the directive was advisory only; now it is a mandatory requirement: Go toolchains refuse to use modules declaring newer Go versions.
  3. The go directive also, since Go 1.21, also is no longer advisory, but mandatory. This means that by changing it as of this version has become a breaking change for anyone importing packages below this version and needs to be handled just like making a breaking change to the package now.

I highly recommend everyone read carefully through the last few Go releases and the Go Mod Reference as dependencies management and managing packages has become much harder; it's easier to make an unintended breaking change than ever before. Also watch out as the Go tooling, I've caught it automatically changing this information without me asking for it.

For other package maintainers that may read this I highly recommend using go build directives to support newer functionality introduced in newer go versions as well as maintaining backward compatibility with older versions, bumping the go.mod Go version is not the solution and is a breaking change, an example can be found here in one of my other packages.

ddymko commented 4 months ago

@deankarn thanks for detailed response