Skip to content

Commit

Permalink
Add Join() from stdlib
Browse files Browse the repository at this point in the history
  • Loading branch information
ToutPetitAdrien committed Jul 23, 2024
1 parent 021cae7 commit bc776b9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
go-version:
- 1.19.x
- 1.21.x
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
Expand Down
12 changes: 12 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,16 @@ func Last(err error, target any) bool {
return false
}

// Join returns an error that wraps the given errors.
// Any nil error values are discarded.
// Join returns nil if every value in errs is nil.
// The error formats as the concatenation of the strings obtained
// by calling the Error method of each element of errs, with a newline
// between each string.
//
// A non-nil error returned by Join implements the Unwrap() []error method.
func Join(errs ...error) error {
return errors.Join(errs...)
}

var errorType = reflect.TypeOf((*error)(nil)).Elem()

0 comments on commit bc776b9

Please sign in to comment.