Documentation
¶
Overview ¶
Package errorsx implements extensions for the standard errors package.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func As ¶ added in v0.10.0
As is a generic version of errors.As.
Example ¶
package main import ( "fmt" "os" "go-simpler.org/errorsx" ) var err error func main() { if pathErr, ok := errorsx.As[*os.PathError](err); ok { fmt.Println(pathErr.Path) } }
Output:
func Close ¶
Close attempts to close the given io.Closer and assigns the returned error (if any) to err. If err is already not nil, it will be joined with the io.Closer's error.
Example ¶
package main import ( "os" "go-simpler.org/errorsx" ) func main() { _ = func() (err error) { f, err := os.Open("file.txt") if err != nil { return err } defer errorsx.Close(f, &err) return nil } }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.