-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: false positive about unrecognized printf flag '0' #23598
Comments
I see a couple of problems in there. |
@robpike could you elaborate? |
Hm... |
Speaking about other problems of '0' flag processing by
In all these cases '0' affects print result, but is reported by |
This does not seem like unreasonable |
Here is an additional test case using fmt.Formatter to let you decide what should be the bahaviour of "go vet": package main
import (
"fmt"
)
type t struct{}
func (_ t) Format(f fmt.State, c rune) {
if f.Flag('0') {
f.Write([]byte("GA"))
} else {
f.Write([]byte("BU"))
}
}
func main() {
fmt.Printf("%0s\n", t{})
} |
https://go-review.googlesource.com/c/go/+/90695 was supposed to mention this issue but got the issue number wrong. |
Fixed by https://golang.org/cl/90695. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?o1.9.3 darwin/amd64
What did you do?
Run
go vet
on the following file:What did you expect to see?
No errors are reported as '0' flag is valid for 't' verb. Program prints
000false
, zeros are used for padding instead of spaces.What did you see instead?
vet
reportsunrecognized printf flag for verb 't': '0'
.The text was updated successfully, but these errors were encountered: