errors: omit redundant nil check in type assertion for Join

When ok is true, err can't be nil.

Make it behave more like the Unwrap function.

Change-Id: Ieba5de57d60f5ff4d6a3468d703e6f72be02a97d
GitHub-Last-Rev: 6df9365a1d
GitHub-Pull-Request: golang/go#74764
Reviewed-on: https://go-review.googlesource.com/c/go/+/689920
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
This commit is contained in:
Jes Cok 2025-07-26 02:49:42 +00:00 committed by Gopher Robot
parent e151db3e06
commit 64ba72474d

View file

@ -28,7 +28,6 @@ func Join(errs ...error) error {
} }
if n == 1 { if n == 1 {
for _, err := range errs { for _, err := range errs {
if err != nil {
if _, ok := err.(interface { if _, ok := err.(interface {
Unwrap() []error Unwrap() []error
}); ok { }); ok {
@ -36,7 +35,6 @@ func Join(errs ...error) error {
} }
} }
} }
}
e := &joinError{ e := &joinError{
errs: make([]error, 0, n), errs: make([]error, 0, n),