Skip to content

cmd/vet: don't complain about innocent newlines. #57059

@robpike

Description

@robpike

What version of Go are you using (go version)?

1.20

Does this issue reproduce with the latest release?

Yes

https://go.dev/play/p/_TMofzRghNL

package main

import "fmt"

const hello = `hello
`

func main() {
	fmt.Println(hello)
}

./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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions