stdversion reports ./foo.go:8:14: reflect.TypeFor requires go1.22 or later (file is go1.21)
I believe that this might be overly strict. Even though the //go:build directive downgrades the language version available in the file, it doesn't change the fact that this file will only be built by a toolchain that is at least verison 1.23, because the module as a whole will only be built by a toolchain that satisfies the go dependency in go.mod.
I thus believe that the standard library available to a file with a build tag is max(file's version, module's version), and not min.
In this example
stdversion reports
./foo.go:8:14: reflect.TypeFor requires go1.22 or later (file is go1.21)
I believe that this might be overly strict. Even though the
//go:build
directive downgrades the language version available in the file, it doesn't change the fact that this file will only be built by a toolchain that is at least verison 1.23, because the module as a whole will only be built by a toolchain that satisfies thego
dependency ingo.mod
.I thus believe that the standard library available to a file with a build tag is
max(file's version, module's version)
, and notmin
./cc @adonovan