Skip to content

Commit a3f192e

Browse files
authored
Merge pull request #30 from peczenyj/fix-errors-join-2
fix: errors.Join defined for go1.19 or below will not work using unsafe.String
2 parents 10bc51a + 40c4e14 commit a3f192e

File tree

3 files changed

+16
-60
lines changed

3 files changed

+16
-60
lines changed

join.go

Lines changed: 0 additions & 59 deletions
This file was deleted.

join_go120.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,16 @@ package errors
55

66
import "errors"
77

8-
var Join = errors.Join
8+
// Join returns an error that wraps the given errors.
9+
// Any nil error values are discarded.
10+
// Join returns nil if every value in errs is nil.
11+
// The error formats as the concatenation of the strings obtained
12+
// by calling the Error method of each element of errs, with a newline
13+
// between each string.
14+
//
15+
// A non-nil error returned by Join implements the Unwrap() []error method.
16+
//
17+
// Available only for go 1.20 or superior.
18+
func Join(errs ...error) error {
19+
return errors.Join(errs...)
20+
}

join_test.go renamed to join_go120_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build go1.20
2+
// +build go1.20
3+
14
package errors_test
25

36
import (

0 commit comments

Comments
 (0)