Remix.run Logo
The Day the Linter Broke My Code(blog.fillmore-labs.com)
25 points by eik 5 days ago | 6 comments
ecnahc515 2 days ago | parent | next [-]

If the the OP is the author, did consider filing a bug with errcheck? It should be possible for errcheck to check if the comparison is being done within an `Is(err error) bool` method and skip the warning in that case, or even better: it could check if your using `errors.Is` within an `Is` method and warn in that case!

eik a day ago | parent [-]

The linter in the post is `err113`. `errortype` does already warn:

https://github.com/fillmore-labs/errortype#errortype

ecnahc515 a day ago | parent [-]

Ah right, wrong linter. Thanks for confirming!

eik 5 days ago | parent | prev | next [-]

Having looked at the problems that can arise with errors.As:

https://news.ycombinator.com/item?id=44959638

Let's now look at how errors.Is can introduce subtle bugs that can affect the reliability of error checking, especially when trying to determine the root cause of an error.

How one letter can make such a difference…

cronelius 2 days ago | parent | prev [-]

Isn't this what Unwrap() is for? errors.Is calls Unwrap if it's available and then compares _that_ error.

eik a day ago | parent [-]

Yes, but “an Is method should only shallowly compare err and the target and not call Unwrap on either”:

https://pkg.go.dev/errors#Is