Skip to content
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

proposal: cmd/vet: Add some popular printf-like methods to hardcoded list #24691

vkuzmin-uber opened this issue Apr 5, 2018 · 6 comments


Copy link

@vkuzmin-uber vkuzmin-uber commented Apr 5, 2018

Please answer these questions before submitting your issue. Thanks!

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

1.9, 1.10

Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?


What did you do?

Use Printf like methods

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on is best.

What did you expect to see?

Standard list should be extended

What did you see instead?

Many errors that can be caught:
go vet -printfuncs=wrapf,statusf,warnf,infof,debugf,failf,equalf,containsf

But many other projects doesn't include it and even are not aware of it. I wrote an article:

Copy link
Contributor Author

@vkuzmin-uber vkuzmin-uber commented Apr 5, 2018

I will provide a CL soon.

Copy link

@gopherbot gopherbot commented Apr 5, 2018

Change mentions this issue: cmd/vet: extend list of printf-like methods

Copy link

@robpike robpike commented Apr 5, 2018

There are three criteria listed in src/cmd/vet/README. For a change for vet to be accepted, it must first satisfy those rules. I am concerned about precision and frequency and maybe even correctness in this case.

It may be that all that's needed and proper is to advertise the flag better, as you have done.

@bcmills bcmills added this to the Go1.11 milestone Apr 6, 2018
Copy link
Contributor Author

@vkuzmin-uber vkuzmin-uber commented Apr 9, 2018

Hi Rob, yes, I understand the concern of precision and frequency. I think that namely: Wrapf, Warnf, Infof, Failf - meets this requirement. I can explain why (I played with sourcegraph

  • Wrapf is from popular package ""
  • warnf, failf ar used even in Go iteself (try git grep -i)
  • infof for consistency and this is also used a lot.

So, if you think we may proceed with these 4 names, let me know. It will be useful.

Also, can you please clarify if there are reason that "go vet" doesn't follow "standard" solution: special attributes at function declaration , like extension of C++ compilers attribute((format (printf,...) or Microsoft SAL Annotations.

If this is an option that we may consider, I am willing to work on proposal.

@robpike robpike changed the title cmd/vet: Add some popular printf-like methods to hardcoded list proposal: cmd/vet: Add some popular printf-like methods to hardcoded list Apr 9, 2018
@gopherbot gopherbot added the Proposal label Apr 9, 2018
Copy link

@rsc rsc commented Apr 9, 2018

The plan is to make vet more able to see the real printf wrappers automatically instead of adding to the list. Let's not change the list please.

@rsc rsc closed this Apr 9, 2018
Copy link

@rsc rsc commented Apr 20, 2018

See for the approach I was talking about (not yet ready for review but you can play with it).

@golang golang locked and limited conversation to collaborators Apr 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.