Comparing errors with == is bug-prone as it doesn't return true if the checked error type is wrapped in the error (e.g. by using fmt.Errorf with %w).
The recommended way to assert error type assertion is using errors.Is.
Note: since neither the io nor the zstd library seem to return wrapped errors, it's not an issue in your usecase, but maybe it will be in the future 😉
Tiny fix:
Comparing errors with
==
is bug-prone as it doesn't returntrue
if the checked error type is wrapped in the error (e.g. by usingfmt.Errorf
with%w
). The recommended way to assert error type assertion is usingerrors.Is
.See also the official error value FAQ.
Note: since neither the
io
nor thezstd
library seem to return wrapped errors, it's not an issue in your usecase, but maybe it will be in the future 😉