go icon indicating copy to clipboard operation
go copied to clipboard

Compare errors using `errors.Is`

Open luxas opened this issue 2 years ago • 0 comments

Hi, thanks for this nice project :sparkles:!

Now, as of Go 1.13 if I recall correctly, there is a new way to compare errors using the errors.Is method in the standard library. This could be done instead of checking for equality directly if err != io.EOF e.g. like here. This allows for custom errors to be returned from e.g. the underlying io.Reader and still be compliant to errors.Is(err, io.EOF) as the error returned implements the Is(err error) bool interface, as described in the errors package.

I would be happy to contribute this change if approved :)

luxas avatar Aug 30 '21 15:08 luxas