From 7a0ec450bd0b2b38eecb5b94eaec485f4a6debbd Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 28 Mar 2023 19:18:19 -0400 Subject: [PATCH] errors: improve godoc for Join and Unwrap Clarify how to deconstruct the error returned by errors.Join, and how Unwrap interacts with errors.Join. --- src/errors/join.go | 2 ++ src/errors/wrap.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/errors/join.go b/src/errors/join.go index 329082a5e3b481..1c486d591e35bf 100644 --- a/src/errors/join.go +++ b/src/errors/join.go @@ -10,6 +10,8 @@ package errors // 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 { n := 0 for _, err := range errs { diff --git a/src/errors/wrap.go b/src/errors/wrap.go index a719655b10dbbf..1f54b66e5cbf67 100644 --- a/src/errors/wrap.go +++ b/src/errors/wrap.go @@ -12,7 +12,8 @@ import ( // type contains an Unwrap method returning error. // Otherwise, Unwrap returns nil. // -// Unwrap returns nil if the Unwrap method returns []error. +// Unwrap only calls a method of the form "Unwrap() error". +// In particular Unwrap does not unwrap errors returned by [Join]. func Unwrap(err error) error { u, ok := err.(interface { Unwrap() error