Skip to content

Commit 7a0ec45

Browse files
committed
errors: improve godoc for Join and Unwrap
Clarify how to deconstruct the error returned by errors.Join, and how Unwrap interacts with errors.Join.
1 parent c520693 commit 7a0ec45

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Diff for: src/errors/join.go

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ package errors
1010
// The error formats as the concatenation of the strings obtained
1111
// by calling the Error method of each element of errs, with a newline
1212
// between each string.
13+
//
14+
// A non-nil error returned by Join implements the Unwrap() []error method.
1315
func Join(errs ...error) error {
1416
n := 0
1517
for _, err := range errs {

Diff for: src/errors/wrap.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import (
1212
// type contains an Unwrap method returning error.
1313
// Otherwise, Unwrap returns nil.
1414
//
15-
// Unwrap returns nil if the Unwrap method returns []error.
15+
// Unwrap only calls a method of the form "Unwrap() error".
16+
// In particular Unwrap does not unwrap errors returned by [Join].
1617
func Unwrap(err error) error {
1718
u, ok := err.(interface {
1819
Unwrap() error

0 commit comments

Comments
 (0)