Skip to content

Commit

Permalink
fix: errors.Join defined for go1.19 or below will not work using unsa…
Browse files Browse the repository at this point in the history
…fe.String, since it is not available on previous go versions
  • Loading branch information
peczenyj committed Nov 17, 2023
1 parent 10bc51a commit 5237bc6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 60 deletions.
59 changes: 0 additions & 59 deletions join.go

This file was deleted.

14 changes: 13 additions & 1 deletion join_go120.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,16 @@ package errors

import "errors"

var Join = errors.Join
// 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.
//
// Available only for go 1.20 or superior.
func Join(errs ...error) error {
return errors.Join(errs...)
}
3 changes: 3 additions & 0 deletions join_test.go → join_go120_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build go1.20
// +build go1.20

package errors_test

import (
Expand Down

0 comments on commit 5237bc6

Please sign in to comment.