[tools] go/analysis/passes/printf: stop reporting trailing newlines in Println

0 views
Skip to first unread message

Alan Donovan (Gerrit)

unread,
Jul 25, 2026, 12:01:56 AM (yesterday) Jul 25
to shuang cui, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Carlos Amedee, golang...@luci-project-accounts.iam.gserviceaccount.com, Michael Matloob, Robert Findley, Gopher Robot, golang-co...@googlegroups.com

Alan Donovan submitted the change

Change information

Commit message:
go/analysis/passes/printf: stop reporting trailing newlines in Println

The printf analyzer reports a redundant newline when the final string
argument to a Println-like function ends in a newline.

The newline is not redundant: Println adds another newline, so the call
produces two line breaks. This may be intentional, for example when
printing a blank line after some text.

Remove this diagnostic and update the existing test cases to verify that
such calls are accepted.

Fixes golang/go#80256
Change-Id: Ic2f43c5639ad21aa53546eba04842647d2047e72
Reviewed-by: Alan Donovan <adon...@google.com>
Reviewed-by: Carlos Amedee <car...@golang.org>
Files:
  • M go/analysis/passes/printf/printf.go
  • M go/analysis/passes/printf/testdata/src/a/a.go
Change size: S
Delta: 2 files changed, 2 insertions(+), 11 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: Ic2f43c5639ad21aa53546eba04842647d2047e72
Gerrit-Change-Number: 804941
Gerrit-PatchSet: 2
Gerrit-Owner: shuang cui <imc...@gmail.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Carlos Amedee <car...@golang.org>
Gerrit-Reviewer: shuang cui <imc...@gmail.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Michael Matloob <mat...@golang.org>
Gerrit-CC: Robert Findley <rfin...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages