-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add perfsprint linter #3714
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
Add perfsprint linter #3714
Conversation
Hey, thank you for opening your first Pull Request ! |
In order for a pull request adding a linter to be reviewed, the linter and the PR must follow some requirements.
Pull Request Description
Linter
The Linter Tests Inside Golangci-lint
|
This would close #3479. @catenacyber have you checked your linter against the testcases of https://github.com/gostaticanalysis/numtostr? |
@leonklingele both linters are similar but target different functions : Sprint or Sprintf I think this linter should also target "%x" as a format string... |
Just pushed a fixup commit to get |
The items on the checklist should be handled. |
Thanks for the feedback
Just put one |
indeed |
@catenacyber hi! I deeply reviewed your linter and found a lot of concerns (and fixed the most part of them). Critical:
Optional: The good new – I run my branch on a some largest Go projects and found a lot of issues. c.UI.Info(fmt.Sprintf("%s", pair.Key)) // Key string Your linter did a great job 👍 |
Thank you Anton, I will look into this :-) |
This comment was marked as off-topic.
This comment was marked as off-topic.
So, what is left to do now ? |
you have to update your PR and create a new tag for your linter to be able to update it inside your PR. |
528c90e
to
40d37cd
Compare
Just tagged a new release and updated my PR. How does that look ? |
40d37cd
to
ba81211
Compare
Have you tried your PR locally? |
FYI it doesn't compile because of a missing rename. |
1a7f4b3
to
71df6c3
Compare
I still get the panic locally but I do not understand why |
276a22c
to
1219bec
Compare
please don't push force: you have removed my commits 2 times. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The single question highlighted by @catenacyber is requiring type cast in rare cases like:
// Before
dummyVMFullName := dummyVMPrefixName + "-" + fmt.Sprint(fnvHash.Sum32())
// After
dummyVMFullName := dummyVMPrefixName + "-" + strconv.FormatUint(uint64(fnvHash.Sum32()), 10)
But I do not consider this as a blocker due to linter performance nature (not style or readability).
Should be covered by catenacyber/perfsprint#7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I am fine with this as first version. |
https://github.com/catenacyber/perfsprint
This is a linter for performance, aiming at usages of
fmt.Sprintf
which have faster alternatives in the standard library such asstrconv.Itoa
I hope I did this correctly by following https://golangci-lint.run/contributing/new-linters/ and https://disaev.me/p/writing-useful-go-analysis-linter/
make vendor README.md
did not workSee golang/go#59144 for an example on the Go std lib