package
module
Version:
v1.0.0
Opens a new window with list of versions in this module.
Published: Dec 26, 2023
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 7
Opens a new window with list of known importers.
README
¶
Slightly better errors package
Just so you don't have to construct a holding variable separately and can write just this:
if err, ok := errors.As[*someError](err); ok {
// ...
}
Documentation
¶
Package errors is a wrapper for `errors` package from standard library
that takes advantage of recently introduced generics.
Function As is replaced to allow the following:
if err, ok := errors.As[*someError](err); ok {
...
}
Rest of the standard `errors` package is re-exported as is.
As works just like `errors.As`, but it takes care of boilerplate for you.
Instead of:
var myErr *someError
if errors.As(err, &myErr) {
...
}
you can write this:
if err, ok := errors.As[*someError](err); ok {
...
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.