Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func As ¶
As is a variant of errors.As() that leverages generics to present a nicer interface.
//this code: var perr os.PathError if errors.As(err, &perr) { handle(perr) } //can be rewritten as: if perr, ok := errext.As[os.PathError](err); ok { handle(perr) }
This is sometimes more verbose (like in this example), but allows to scope the specific error variable to the condition's then-branch, and also looks more idiomatic to developers already familiar with type casts.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.