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

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

Comments

Projects
None yet
5 participants
@vkuzmin-uber
Copy link
Contributor

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?

Yes

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

darwin_amd64

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 play.golang.org 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:
https://kuzminva.wordpress.com/2017/11/07/go-vet-printf-family-check/

@vkuzmin-uber

This comment has been minimized.

Copy link
Contributor Author

commented Apr 5, 2018

I will provide a CL soon.

@gopherbot

This comment has been minimized.

Copy link

commented Apr 5, 2018

Change https://golang.org/cl/104835 mentions this issue: cmd/vet: extend list of printf-like methods

@robpike

This comment has been minimized.

Copy link
Contributor

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

@vkuzmin-uber

This comment has been minimized.

Copy link
Contributor Author

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 https://sourcegraph.com/search?q=wrapf+infof+warnf+failf):

  • Wrapf is from popular package "github.com/pkg/errors"
  • 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

@rsc

This comment has been minimized.

Copy link
Contributor

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

@rsc

This comment has been minimized.

Copy link
Contributor

commented Apr 20, 2018

See https://go-review.googlesource.com/#/c/go/+/108559 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.
You can’t perform that action at this time.