-
Notifications
You must be signed in to change notification settings - Fork 17.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/vet: don't complain about innocent newlines. #57059
Comments
This particular message dates from the original commit of vet. (I reworded it to add the word 'redundant' later.) The extra precision of examining named constant arguments was introduced in Go 1.18.
This combination of factors suggests to me that we probably should leave things working as they are today:
Overall, it seems reasonable for vet to flag this case, which does require rewriting code that truly wants a blank line to make that intent clearer, such as by adding the blank line to the large constant literal and using fmt.Fprint. |
Relevant recent discussion #49350
We could plausibly suppress the "*ln" checks when the ast is exactly an identifier for a constant. The challenge here is it is going to be hard for users to predict when this warning applies and when it does not. Why does The other plausible distinguishing feature is that the surprises seem to occur when a `-quoted string literal is involved. We could suppress "*ln" warnings on those and constants that are set to be equal to those. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
https://go.dev/play/p/_TMofzRghNL
./x.go:9:2: fmt.Println arg list ends with redundant newline
I understand the desire to complain if there is an explicit newline in the text to fmt.Println, but when it's coming from a constant like this, I need to change the constant or use Print instead of Println. I keep hitting this problem with old code that has a nice header to be printed that desires a blank line. Requiring me to close the constant before the newline seems excessively fussy to me.
The text was updated successfully, but these errors were encountered: