fatih / errwrap

Go tool to wrap and fix errors with the new %w verb directive
https://arslan.io
Other
371 stars 16 forks source link

feat: detect and fix err.String() calls #12

Closed dnwe closed 3 years ago

dnwe commented 4 years ago

Adds support for detecting and fixing the following Errorf case where the developer had previously add a call to .Error() in their Errorf statement:

-fmt.Errorf("failed for %s with error: %s", "foo", err.Error())
+fmt.Errorf("failed for %s with error: %w", "foo", err)

This PR also switches to running the tests with the new analysistest.RunWithSuggestedFixes helper to verify the -fix behaviour using golden files.

fatih commented 3 years ago

I like this change. Also, thanks for introducing analysistest.RunWithSuggestedFixes. Sorry for the late response. I moved from another continent with the whole family and just started having some time for myself.

fatih commented 3 years ago

This feature is now included in v1.3.1: https://github.com/fatih/errwrap/releases/tag/v1.3.1

dnwe commented 3 years ago

@fatih thanks!