tomarrell / wrapcheck

A Go linter to check that errors from external packages are wrapped
https://blog.tomarrell.com/post/introducing_wrapcheck_linter_for_go
MIT License
302 stars 27 forks source link

Update README.md #28

Closed rozanecm closed 2 years ago

rozanecm commented 2 years ago

Use %w in fmt.Errorf instead of %v or %s. Following go-errorlint's suggestions.

tomarrell commented 2 years ago

G'day. Thanks for the suggestion, however, this has previously been discussed in #18. The use of %v here is intentional.

I recommend using %v, until you know you want to inspect an error, and only in that case using %w. Otherwise, you risk unintentionally exposing errors as part of your public API. This is also presented in the go-errorlint README as a caveat of using %w.