diff --git a/src/cmd/go.mod b/src/cmd/go.mod
index 017883a..b8ec066 100644
--- a/src/cmd/go.mod
+++ b/src/cmd/go.mod
@@ -11,7 +11,7 @@
golang.org/x/sys v0.36.0
golang.org/x/telemetry v0.0.0-20250908211612-aef8a434d053
golang.org/x/term v0.34.0
- golang.org/x/tools v0.37.1-0.20250924232827-4df13e317ce4
+ golang.org/x/tools v0.37.1-0.20250926142134-e90843045cbb
)
require (
diff --git a/src/cmd/go.sum b/src/cmd/go.sum
index 0906ffc..da94abb 100644
--- a/src/cmd/go.sum
+++ b/src/cmd/go.sum
@@ -22,7 +22,7 @@
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
-golang.org/x/tools v0.37.1-0.20250924232827-4df13e317ce4 h1:IcXDtHggZZo+GzNzvVRPyNFLnOc2/Z1gg3ZVIWF2uCU=
-golang.org/x/tools v0.37.1-0.20250924232827-4df13e317ce4/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
+golang.org/x/tools v0.37.1-0.20250926142134-e90843045cbb h1:Ot2mS7bIzGm604crIWkHNcDm9l6GFM67+XMo/us4gkw=
+golang.org/x/tools v0.37.1-0.20250926142134-e90843045cbb/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef h1:mqLYrXCXYEZOop9/Dbo6RPX11539nwiCNBb1icVPmw8=
rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef/go.mod h1:8xcPgWmwlZONN1D9bjxtHEjrUtSEa3fakVF8iaewYKQ=
diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go
index 6e32f29..91aac67 100644
--- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go
+++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go
@@ -15,6 +15,8 @@
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
+ "golang.org/x/tools/internal/analysisinternal"
+ "golang.org/x/tools/internal/versions"
)
const Doc = "check //go:build and // +build directives"
@@ -55,7 +57,6 @@
func checkGoFile(pass *analysis.Pass, f *ast.File) {
var check checker
check.init(pass)
- defer check.finish()
for _, group := range f.Comments {
// A +build comment is ignored after or adjoining the package declaration.
@@ -77,6 +78,27 @@
check.comment(c.Slash, c.Text)
}
}
+
+ check.finish()
+
+ // For Go 1.18+ files, offer a fix to remove the +build lines
+ // if they passed all consistency checks.
+ if check.crossCheck && !versions.Before(pass.TypesInfo.FileVersions[f], "go1.18") {
+ for _, rng := range check.plusBuildRanges {
+ check.pass.Report(analysis.Diagnostic{
+ Pos: rng.Pos(),
+ End: rng.End(),
+ Message: "+build line is no longer needed",
+ SuggestedFixes: []analysis.SuggestedFix{{
+ Message: "Remove obsolete +build line",
+ TextEdits: []analysis.TextEdit{{
+ Pos: rng.Pos(),
+ End: rng.End(),
+ }},
+ }},
+ })
+ }
+ }
}
func checkOtherFile(pass *analysis.Pass, filename string) error {
@@ -96,15 +118,15 @@
}
type checker struct {
- pass *analysis.Pass
- plusBuildOK bool // "+build" lines still OK
- goBuildOK bool // "go:build" lines still OK
- crossCheck bool // cross-check go:build and +build lines when done reading file
- inStar bool // currently in a /* */ comment
- goBuildPos token.Pos // position of first go:build line found
- plusBuildPos token.Pos // position of first "+build" line found
- goBuild constraint.Expr // go:build constraint found
- plusBuild constraint.Expr // AND of +build constraints found
+ pass *analysis.Pass
+ plusBuildOK bool // "+build" lines still OK
+ goBuildOK bool // "go:build" lines still OK
+ crossCheck bool // cross-check go:build and +build lines when done reading file
+ inStar bool // currently in a /* */ comment
+ goBuildPos token.Pos // position of first go:build line found
+ plusBuildRanges []analysis.Range // range of each "+build" line found
+ goBuild constraint.Expr // go:build constraint found
+ plusBuild constraint.Expr // AND of +build constraints found
}
func (check *checker) init(pass *analysis.Pass) {
@@ -272,6 +294,8 @@
}
func (check *checker) plusBuildLine(pos token.Pos, line string) {
+ plusBuildRange := analysisinternal.Range(pos, pos+token.Pos(len(line)))
+
line = strings.TrimSpace(line)
if !constraint.IsPlusBuild(line) {
// Comment with +build but not at beginning.
@@ -286,9 +310,7 @@
check.crossCheck = false
}
- if check.plusBuildPos == token.NoPos {
- check.plusBuildPos = pos
- }
+ check.plusBuildRanges = append(check.plusBuildRanges, plusBuildRange)
// testing hack: stop at // ERROR
if i := strings.Index(line, " // ERROR "); i >= 0 {
@@ -336,19 +358,19 @@
}
func (check *checker) finish() {
- if !check.crossCheck || check.plusBuildPos == token.NoPos || check.goBuildPos == token.NoPos {
+ if !check.crossCheck || len(check.plusBuildRanges) == 0 || check.goBuildPos == token.NoPos {
return
}
// Have both //go:build and // +build,
// with no errors found (crossCheck still true).
// Check they match.
- var want constraint.Expr
lines, err := constraint.PlusBuildLines(check.goBuild)
if err != nil {
check.pass.Reportf(check.goBuildPos, "%v", err)
return
}
+ var want constraint.Expr
for _, line := range lines {
y, err := constraint.Parse(line)
if err != nil {
@@ -363,7 +385,8 @@
}
}
if want.String() != check.plusBuild.String() {
- check.pass.Reportf(check.plusBuildPos, "+build lines do not match //go:build condition")
+ check.pass.ReportRangef(check.plusBuildRanges[0], "+build lines do not match //go:build condition")
+ check.crossCheck = false // don't offer fix to remove +build
return
}
}
diff --git a/src/cmd/vendor/modules.txt b/src/cmd/vendor/modules.txt
index 1332713..8203a31 100644
--- a/src/cmd/vendor/modules.txt
+++ b/src/cmd/vendor/modules.txt
@@ -73,7 +73,7 @@
golang.org/x/text/language
golang.org/x/text/transform
golang.org/x/text/unicode/norm
-# golang.org/x/tools v0.37.1-0.20250924232827-4df13e317ce4
+# golang.org/x/tools v0.37.1-0.20250926142134-e90843045cbb
## explicit; go 1.24.0
golang.org/x/tools/cmd/bisect
golang.org/x/tools/cover