Skip to content

Commit

Permalink
errors: improve godoc for Join and Unwrap
Browse files Browse the repository at this point in the history
Clarify how to deconstruct the error returned by errors.Join, and how Unwrap interacts
with errors.Join.
  • Loading branch information
dnephin committed Mar 29, 2023
1 parent c520693 commit 0e54a91
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/errors/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/errors/wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// type contains an Unwrap method returning error.
// Otherwise, Unwrap returns nil.
//
// Unwrap returns nil if the Unwrap method returns []error.
// Unwrap returns nil if err has an Unwrap method that returns []error.
func Unwrap(err error) error {
u, ok := err.(interface {
Unwrap() error
Expand Down

0 comments on commit 0e54a91

Please sign in to comment.