-
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: spurious error message non-constant format string in call to mypkg/errors.New #71695
Comments
please show a complete reproducer. |
Related Issues (Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
To be clear: the intent of the check is catch mistakes of this form: https://go.dev/play/p/6dPT8b-lyZa func main() {
oops("this is 100% wrong!")
}
func oops(s string) {
log.Printf(s) // "2009/11/10 23:00:00 this is 100%!w(MISSING)rong!"
} |
Thanks Alan. On the other hand, if we had
we would probably not want to see a go vet warning. |
I believe the check is transitive: package main
import "log"
func main() {
var s string
oops("foo") // won't warn
oops(s) // will warn
}
func oops(s string, args ...any) {
log.Printf(s, args...)
} |
In any case you won't get a warning if arguments are being passed. If you think there is a bug here, please show us the code that is triggering an incorrect warning. Thanks. |
OK, I'll try to extract a small example this weekend. |
Alan, Ian and Sean I have now checked a sample of these errors generated when running go vet over my codebase I am therefore closing the ticket. |
Thanks for following up. |
This is the main error we got when compiling everything: golang/go#71695 Signed-off-by: Taylor Silva <dev@taydev.net>
Go version
go version go1.24.0 darwin/arm64
Output of
go env
in your module/workspace:GOVERSION='go1.24.0'
What did you do?
ran go vet
What did you see happen?
errors the of form
This is a message is incorrect, as mypkg/errors.New does explicitly allow format strings.
The message would have been correct if I would have called errors.New() from stdlib
but mypkg/errors.New is a different function with a different signature.
What did you expect to see?
no errors
The text was updated successfully, but these errors were encountered: