go/build: check result of strings.Cut

Change-Id: Id393d916db51cced261c0ec1e24957dc310a4c9b
GitHub-Last-Rev: 5b7c262b73
GitHub-Pull-Request: golang/go#78756
Reviewed-on: https://go-review.googlesource.com/c/go/+/767200
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Weixie Cui 2026-04-15 13:05:47 +00:00 committed by Gopher Robot
parent 3b345adf2c
commit 620cefa291

View file

@ -66,7 +66,10 @@ func minVersion(z Expr, sign int) int {
if z.Tag == "go1" {
return 0
}
_, v, _ := strings.Cut(z.Tag, "go1.")
_, v, ok := strings.Cut(z.Tag, "go1.")
if !ok {
return -1
}
n, err := strconv.Atoi(v)
if err != nil {
// not a go1.N tag