{"repo":"fatih/errwrap","free":true,"listed":false,"github":"https://github.com/fatih/errwrap","clone":"git clone https://github.com/fatih/errwrap.git","description":"Go tool to wrap and fix errors with the new %w verb directive","language":"Go","stars":379,"topics":["go","golang","tools","analyzer","errwrap"],"license":null,"category":"dev-tools","readme_excerpt":"errwrap Wrap and fix Go errors with the new %w verb directive. This tool analyzes fmt.Errorf() calls and reports calls that contain a verb directive that is different than the new %w verb directive introduced in Go v1.13. It's also capable of rewriting calls to use the new %w wrap verb directive. Install or download one of the pre-compiled binaries from the releases page and copy to the desired location. Usage By default, errwrap prints the output of the analyzer to stdout. You can pass a file, directory or a Go package: When called it displays the error with the line and column: errwrap is also able to rewrite your source code to replace any verb directive used for an error type with the %w verb directive. Assume we have the following source code: Calling errwrap with the -fix flag will rewrite the source code: Whether to Wrap or not? Wrapping an error is not always the best approach. Wrapping exposes the underlying error and makes it part of your public API. This means clients who rely on them could see breaking changes if you change your underlying implementation or don't wrap anymore. The blog post Working with Errors in Go 1.13 contains a section called Whether to Wrap that explains this in more detail Credits This tool is built on top of the excellent go/analysis package that makes it easy to write custom analyzers in Go. If you're interested in writing a tool, check out my Using go/analysis to write a custom linter blog post. Also part of the code that parses the verb ","default_branch":null,"files":null,"tree":[],"storefront":"/r/fatih","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/fatih/errwrap/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}