Closed kolyshkin closed 2 years ago
Yup, you should be able to make that comparison.
I think the best way to resolve this is to check whether the expression is in the scope of a function that adheres tot the Is
signature. A linter exception is also possible, but I'd rather not make a roundtrip to the caveat section of the readme needed for something so common.
Unfortunately, I am very short on time and energy. If you need this to be resolved soon I recommend submitting a PR or adding a linter exception for now.
or adding a linter exception for now
That is what I did for now. Might try to properly fix this in go-errorlint later...
I wrote some code with a custom error type:
Basically, the idea is to make
errors.Is(err, ErrInvalidConfig)
to returntrue
for every error which is wrapped ininvalidConfig
type.Now, the comparison linter complains:
Which is obviously incorrect because
Is
method, i.e.target
, is not supposed to be unwrapped.errors.Is
in the above example will result in infinite recursion.There's a similar code in goland standard library (src/syscall/syscall_unix.go):
Note that
target
is compared withoserror.*
directly.