]> Cypherpunks repositories - gostls13.git/commit
cmd/vet: don't warn on escaped newlines in Println
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 7 Nov 2017 11:34:35 +0000 (11:34 +0000)
committerDaniel Martí <mvdan@mvdan.cc>
Fri, 10 Nov 2017 09:08:06 +0000 (09:08 +0000)
commit366681cc06357cfdca91c18eff059e11e5470383
tree878b7a7405059fd129740fba1d56c465a459416e
parent2a668e2467ddea57e8a1ab2859cfd49e6ab2dd40
cmd/vet: don't warn on escaped newlines in Println

The old code only worked for double-quoted strings, and only checked
that the end of the literal value was \n". This worked most of the time,
except for some strings like "foo\\n", which doesn't actually translate
into a trailing newline when unquoted.

To fix this, unquote the string first and look for a real newline at the
end of it. Ignore errors, as we don't have anything to do with string
literals using back quotes.

Fixes #22613.

Change-Id: I7cf96916dd578b7068216c2051ec2622cce0b740
Reviewed-on: https://go-review.googlesource.com/76194
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/vet/print.go
src/cmd/vet/testdata/print.go