// GoVersion describes the accepted Go language version. The string
// must follow the format "go%d.%d" (e.g. "go1.12") or ist must be
- // empty; an empty string indicates the latest language version.
+ // empty; an empty string disables Go language version checks.
// If the format is invalid, invoking the type checker will cause a
// panic.
GoVersion string
// build lines were ignored and code got the module's Go version.
// To work around this, downgrades are only allowed when the
// module's Go version is Go 1.21 or later.
- if v.before(check.version) && check.version.before(version{1, 21}) {
+ // If there is no check.version, then we don't really know what Go version to apply.
+ // Legacy tools may do this, and they historically have accepted everything.
+ // Preserve that behavior by ignoring //go:build constraints entirely in that case.
+ if (v.before(check.version) && check.version.before(version{1, 21})) || check.version.equal(version{0, 0}) {
continue
}
if check.posVers == nil {
// GoVersion describes the accepted Go language version. The string
// must follow the format "go%d.%d" (e.g. "go1.12") or it must be
- // empty; an empty string indicates the latest language version.
+ // empty; an empty string disables Go language version checks.
// If the format is invalid, invoking the type checker will cause a
// panic.
GoVersion string
// build lines were ignored and code got the module's Go version.
// To work around this, downgrades are only allowed when the
// module's Go version is Go 1.21 or later.
- if v.before(check.version) && check.version.before(version{1, 21}) {
+ // If there is no check.version, then we don't really know what Go version to apply.
+ // Legacy tools may do this, and they historically have accepted everything.
+ // Preserve that behavior by ignoring //go:build constraints entirely in that case.
+ if (v.before(check.version) && check.version.before(version{1, 21})) || check.version.equal(version{0, 0}) {
continue
}
if check.posVers == nil {