Skip to content

v1.8.0: new module `oserror`

Compare
Choose a tag to compare
@knz knz released this 29 Oct 20:00
· 120 commits to master since this release
b41978a

This version of the library includes working replacements for error predicates in os, via a new sub-package oserror.

These new functions oserror.IsTimeout(), oserror.IsExist(), oserror.IsNotExist() and oserror.IsPermission() can recognize the same errors as their analog in package os, with the following improvements:

  • they are able to peek through layers of error wrappers, which the functions in os cannot;
  • they are able to recognize errors across the network, through Encode / Decode cycles.

Note that the new functions will not be able to identify os errors encoded using a previous version of the library, unless they were encoded on exactly the same OS / platform combination (identified by GOARCH/GOOS). Therefore, care should be taken to ensure all components in a distributed system are upgraded to the newer version before the predicates can be used safely for errors transported over the network.