1
0
mirror of https://github.com/golang/go synced 2024-09-29 04:34:32 -06:00

errors: improve godoc for Join and Unwrap

Clarify how to deconstruct the error returned by errors.Join, and how Unwrap interacts
with errors.Join.
This commit is contained in:
Daniel Nephin 2023-03-28 19:18:19 -04:00
parent c52069361a
commit 7a0ec450bd
2 changed files with 4 additions and 1 deletions

View File

@ -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 {

View File

@ -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