diff options
author | Jonathan Amsterdam <jba@google.com> | 2019-09-04 13:01:16 -0400 |
---|---|---|
committer | Jonathan Amsterdam <jba@google.com> | 2019-09-04 17:08:55 +0000 |
commit | d9a3d902ec139c95d8dc1b69977783fb8134b552 (patch) | |
tree | b3c37e549abcb85f76e4eb18a5f4456ddbfc41e9 /src | |
parent | 6fcc2d85be557c6890a1ad50ee280fa3cd8088e6 (diff) | |
download | go-git-d9a3d902ec139c95d8dc1b69977783fb8134b552.tar.gz |
errors: fix wrong code in package doc
You can't call Unwrap on the return value of fmt.Errorf, but
you can pass the result to errors.Unwrap.
Also, move the description of the Unwrap function up so the
example makes sense.
Fixes #34061.
Change-Id: Ica07c44665c5e65deea4aa6a146fc543a5a0a99d
Reviewed-on: https://go-review.googlesource.com/c/go/+/193298
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Katie Hockman <katie@golang.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/errors/errors.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/errors/errors.go b/src/errors/errors.go index 85d4260762..d923ad4b70 100644 --- a/src/errors/errors.go +++ b/src/errors/errors.go @@ -13,16 +13,16 @@ // // If e.Unwrap() returns a non-nil error w, then we say that e wraps w. // +// Unwrap unpacks wrapped errors. If its argument's type has an +// Unwrap method, it calls the method once. Otherwise, it returns nil. +// // A simple way to create wrapped errors is to call fmt.Errorf and apply the %w verb // to the error argument: // -// fmt.Errorf("... %w ...", ..., err, ...).Unwrap() +// errors.Unwrap(fmt.Errorf("... %w ...", ..., err, ...)) // // returns err. // -// Unwrap unpacks wrapped errors. If its argument's type has an -// Unwrap method, it calls the method once. Otherwise, it returns nil. -// // Is unwraps its first argument sequentially looking for an error that matches the // second. It reports whether it finds a match. It should be used in preference to // simple equality checks: |