Change information
Commit message:
go/analysis/passes/modernize: fix duplicate //go:fix inline directive
The newexpr analyzer used strings.Contains to check whether a
//go:fix inline directive already exists, which could fail to
detect existing directives in edge cases.
Use astutil.Directives for structured matching instead,
preventing duplicate //go:fix inline lines when go fix
is run multiple times.
Fixes golang/go#78196
Change-Id: I7a5d32deb57fe7a90f472d6e49cc5f485a9b13f4
GitHub-Last-Rev: e5ba0820c3eb4800e4e92c6e339d852aa26785ba
GitHub-Pull-Request: golang/tools#622
Files:
- M go/analysis/passes/modernize/newexpr.go
- M go/analysis/passes/modernize/testdata/src/newexpr/newexpr.go
- M go/analysis/passes/modernize/testdata/src/newexpr/newexpr.go.golden
Change size: S
Delta: 3 files changed, 14 insertions(+), 5 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +1 by Hyang-Ah Hana Kim, +2 by Madeline Kalil
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI