Skip to content

Commit e71702b

Browse files
timothy-kingGo LUCI
authored and
Go LUCI
committed
internal/versions: remove constraint.GoVersion wrapper
Remove the constraint.GoVersion wrapper as x/tools can now assume >=go1.21. Change-Id: I3bd0669d28cabc26cf63c299b3eb51c6a6adc0d0 Reviewed-on: https://go-review.googlesource.com/c/tools/+/632356 Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Commit-Queue: Tim King <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent c99edec commit e71702b

File tree

3 files changed

+6
-46
lines changed

3 files changed

+6
-46
lines changed

go/analysis/passes/buildtag/buildtag.go

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515

1616
"golang.org/x/tools/go/analysis"
1717
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
18-
"golang.org/x/tools/internal/versions"
1918
)
2019

2120
const Doc = "check //go:build and // +build directives"
@@ -371,11 +370,6 @@ func (check *checker) finish() {
371370

372371
// tags reports issues in go versions in tags within the expression e.
373372
func (check *checker) tags(pos token.Pos, e constraint.Expr) {
374-
// Check that constraint.GoVersion is meaningful (>= go1.21).
375-
if versions.ConstraintGoVersion == nil {
376-
return
377-
}
378-
379373
// Use Eval to visit each tag.
380374
_ = e.Eval(func(tag string) bool {
381375
if malformedGoTag(tag) {
@@ -393,26 +387,19 @@ func malformedGoTag(tag string) bool {
393387
// Check for close misspellings of the "go1." prefix.
394388
for _, pre := range []string{"go.", "g1.", "go"} {
395389
suffix := strings.TrimPrefix(tag, pre)
396-
if suffix != tag {
397-
if valid, ok := validTag("go1." + suffix); ok && valid {
398-
return true
399-
}
390+
if suffix != tag && validGoVersion("go1."+suffix) {
391+
return true
400392
}
401393
}
402394
return false
403395
}
404396

405397
// The tag starts with "go1" so it is almost certainly a GoVersion.
406398
// Report it if it is not a valid build constraint.
407-
valid, ok := validTag(tag)
408-
return ok && !valid
399+
return !validGoVersion(tag)
409400
}
410401

411-
// validTag returns (valid, ok) where valid reports when a tag is valid,
412-
// and ok reports determining if the tag is valid succeeded.
413-
func validTag(tag string) (valid bool, ok bool) {
414-
if versions.ConstraintGoVersion != nil {
415-
return versions.ConstraintGoVersion(&constraint.TagExpr{Tag: tag}) != "", true
416-
}
417-
return false, false
402+
// validGoVersion reports when a tag is a valid go version.
403+
func validGoVersion(tag string) bool {
404+
return constraint.GoVersion(&constraint.TagExpr{Tag: tag}) != ""
418405
}

internal/versions/constraint.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

internal/versions/constraint_go121.go

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)