go/analysis/passes/modernize: document 'go fix' command Update the modernizer docs to recommend go fix in preference to the the multichecker-based modernize command. Also, delete the gopls/internal/analysis/modernize/cmd/modernize command, which is internal and deprecated. This will break 'go run .../modernize@latest' at the next gopls release. Fixes golang/go#80510 Change-Id: I5b27787b3afdaf86c5c1222b3cc02ab45c138a38 Reviewed-on: https://go-review.googlesource.com/c/tools/+/804000 Auto-Submit: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Hongxiang Jiang <hxjiang@golang.org>
diff --git a/go/analysis/passes/modernize/doc.go b/go/analysis/passes/modernize/doc.go index bf83de3..e441f8d 100644 --- a/go/analysis/passes/modernize/doc.go +++ b/go/analysis/passes/modernize/doc.go
@@ -15,13 +15,16 @@ trivial to fix. We regard any modernizer whose fix changes program behavior to have a serious bug and will endeavor to fix it. -To apply all modernization fixes en masse, you can use the +Since Go 1.26, the 'go fix' command has included the modernize suite, +so to apply all modernization fixes en masse, you can use the following command: - $ go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest -fix ./... + $ go fix ./... -(Do not use "go get -tool" to add gopls as a dependency of your -module; gopls commands must be built from their release branch.) +If you need to run a modernizer added or modified since the Go +release, you can use this standalone command: + + $ go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest -fix ./... If the tool warns of conflicting fixes, you may need to run it more than once until it has applied all fixes cleanly. This command is
diff --git a/gopls/internal/analysis/modernize/cmd/modernize/main.go b/gopls/internal/analysis/modernize/cmd/modernize/main.go deleted file mode 100644 index 0f1f5e6..0000000 --- a/gopls/internal/analysis/modernize/cmd/modernize/main.go +++ /dev/null
@@ -1,21 +0,0 @@ -// Copyright 2024 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// The modernize command suggests (or, with -fix, applies) fixes that -// clarify Go code by using more modern features. -// -// See [golang.org/x/tools/go/analysis/passes/modernize] for details. -// -// Deprecated: use 'go run -// golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize' instead. In -// due course the modernizer suite will be accessed through "go fix"; -// see https://go.dev/issue/71859. -package main - -import ( - "golang.org/x/tools/go/analysis/multichecker" - "golang.org/x/tools/go/analysis/passes/modernize" -) - -func main() { multichecker.Main(modernize.Suite...) }