Skip to content

Commit

Permalink
blog: clarify what is meant by equality in article
Browse files Browse the repository at this point in the history
The blog article https://go.dev/blog/go1.13-errors explains when package
errors use a user-authored Is method on an error. It does this in the
context of error value equality. Because errors are often implemented as
pointer values (and receivers), which may have non-obvious semantics to
newcomers, this presents a good opportunity to remind the reader what
equality means in such cases.

This commit is largely cosmetic and provides a link back to the relevant
part of the language specification.

Change-Id: I0e312fa1385e7caa9944eaff4ac788c91c3294dd
Reviewed-on: https://go-review.googlesource.com/c/website/+/358354
Reviewed-by: Jean de Klerk <[email protected]>
Reviewed-by: Damien Neil <[email protected]>
Trust: Jean de Klerk <[email protected]>
Run-TryBot: Jean de Klerk <[email protected]>
TryBot-Result: Go Bot <[email protected]>
  • Loading branch information
passionSeven committed Oct 25, 2021
1 parent de38da7 commit 4284812
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions go.dev/_content/blog/go1.13-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,10 @@ information to preserve an abstraction layer.
## Customizing error tests with Is and As methods

The `errors.Is` function examines each error in a chain for a match with a
target value. By default, an error matches the target if the two are equal. In
addition, an error in the chain may declare that it matches a target by
implementing an `Is` _method_.
target value. By default, an error matches the target if the two are
[equal](https://golang.org/ref/spec#Comparison_operators). In addition, an
error in the chain may declare that it matches a target by implementing an `Is`
_method_.

As an example, consider this error inspired by the
[Upspin error package](https://commandcenter.blogspot.com/2017/12/error-handling-in-upspin.html)
Expand Down

0 comments on commit 4284812

Please sign in to comment.