Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c0fd7f7

Browse files
dnephingopherbot
authored andcommittedMar 30, 2023
errors: improve the godoc for Join and Unwrap
Document that errors returned by Join always implement Unwrap []error. Explicitly state that Unwrap does not unwrap errors with an Unwrap() []error method. Change-Id: Id610345dcf43ca54a9dde157e56c5815c5112073 GitHub-Last-Rev: 7a0ec45 GitHub-Pull-Request: #59301 Reviewed-on: https://go-review.googlesource.com/c/go/+/480021 Run-TryBot: Emmanuel Odeke <[email protected]> Auto-Submit: Emmanuel Odeke <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Damien Neil <[email protected]>
1 parent 443eb97 commit c0fd7f7

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
 

‎src/errors/join.go

Lines changed: 2 additions & 0 deletions
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 {

‎src/errors/wrap.go

Lines changed: 2 additions & 1 deletion
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)
Please sign in to comment.