-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/vet: printf check misses strings that are + together #30436
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
CC @alandonovan @josharian @mvdan @ianthehat for |
Thanks, this is indeed a bug. The checkPrint function in golang.org/x/tools/go/analysis/passes/printf/printf.go looks for ast.BasicLit, which is a relic of the older implementation which could not assume well-typed syntax trees. Now it's better to look for expressions that are string constants, independent of their syntax, as we do when checking Printf (not Println as in your example). |
Change https://golang.org/cl/356830 mentions this issue: |
This change is finding 3 instances in the Go tree itself:
Filed #49322 for resolving them. |
This would otherwise be caught with the improved vet printf checker (golang/go#30436).
Change https://golang.org/cl/361263 mentions this issue: |
Change https://golang.org/cl/361265 mentions this issue: |
This redundancy is now caught by the improved printf vet checker (#30436). Updates #49322 Change-Id: Id450247adc6fa28a9244c019be3c1b52c2d17f49 Reviewed-on: https://go-review.googlesource.com/c/go/+/361263 Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Zvonimir Pavlinovic <zpavlinovic@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This would otherwise be caught with the improved vet printf checker (golang/go#30436).
* Replace fmt.Println with fmt.Printf for newline-ending string. This would otherwise be caught with the improved vet printf checker (golang/go#30436). * Replace fmt.Println with fmt.Printf for newline-ending string. This would otherwise be caught with the improved vet printf checker (golang/go#30436). * Avoid adding a redundant newline when printing weblistPageClosing.
With this example put into https://play.golang.org/ (and go1.11), there is no warning. Joining the two strings into 1 results in a warning.
Some people split long strings, which is where I encountered it.
The text was updated successfully, but these errors were encountered: