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
x/tools/go/analysis/passes/errorsas: support errors.As provided by other packages #44784
Comments
errors.As
provided by other packages
CC @matloob, @timothy-king. |
errorsas now supports other packages. By default, it checks github.com/pkg/errors and golang.org/x/xerrors, but additional packages can be passed via -pkgs flag. Fixes golang/go#44784
Change https://golang.org/cl/299429 mentions this issue: |
This is worth fixing.
This seems like a reasonable improvement, and there is a precedent for this.
I am not aware of a precedent for supporting modeling [/hard coding knowledge] of libraries outside of the standard library or An option that is more implementation work but would support |
Double checked the current analyzers. I found no examples of analysis modeling any types or functions outside of the standard library or Options I can think of:
|
go/analysis/passes/errorsas
works only with the standard packageerrors
. So, I believe it is useless for many projects which use very populargithub.com/pkg/errors
. Of course, it's possible to aliaserrors
package (for examplestderrors
) and use it, but I think it's better to update the analyzer.I see 2 options here:
github.com/pkg/errors.As
. It's the simplest solution but requires an update for every new packagego/analysis/passes/printf
uses the similar approachI think the best solution is to combine these options: use flags with the default functions
errors.As
andgithub.com/pkg/errors.As
The text was updated successfully, but these errors were encountered: