Skip to content

Commit

Permalink
docs(readme): rewrite
Browse files Browse the repository at this point in the history
Fix #25
  • Loading branch information
ernado committed Jul 3, 2023
1 parent 5818433 commit 9c2dbd4
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,32 @@ errors.Wrap(err, "message")
## Don't need traces?
Call `errors.DisableTrace` or use build tag `noerrtrace`.

## Migration
## Additional features

### Into

Generic type assertion for errors.

```go
// Into finds the first error in err's chain that matches target type T, and if so, returns it.
//
// Into is type-safe alternative to As.
func Into[T error](err error) (val T, ok bool)
```
go get github.com/go-faster/errors/cmd/gowrapper@latest
gowrapper ./...

```go
if pathError, ok := errors.Into[*os.PathError](err); ok {
fmt.Println("Failed at path:", pathError.Path)
}
```

### Must

Must is a generic helper, like template.Must, that wraps a call to a function returning (T, error)
and panics if the error is non-nil.

```go
func Must[T any](val T, err error) T
```

## License
Expand Down

0 comments on commit 9c2dbd4

Please sign in to comment.