]> Cypherpunks repositories - gostls13.git/commit
errors: mention Is methods should not call Unwrap
authorMatt T. Proud <matt.proud@gmail.com>
Tue, 19 Oct 2021 08:09:06 +0000 (10:09 +0200)
committerDamien Neil <dneil@google.com>
Tue, 19 Oct 2021 18:42:57 +0000 (18:42 +0000)
commit7999fd4710e7f987e86d7b32dd9af31ced4810ba
tree6788142cc71e7dab110b1a307e8ffec3b9581bdb
parent6c3cd5d2eb7149c9c1ced7d70c3f4157f27c1588
errors: mention Is methods should not call Unwrap

errors.Is internally unwraps the error until the error matches the
target. Because of this, a user-authored Is method on an error type
need not call errors.Unwrap on itself or the target, because that would
make the unwrapping operation O(N^2). It is a subtle detail to remind
authors for resource efficiency reasons.

Change-Id: Ic1ba59a5bdbfe2c7cb51a2cba2537ab6de4a13ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/356789
Reviewed-by: Jean de Klerk <deklerk@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Jean de Klerk <deklerk@google.com>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Jean de Klerk <deklerk@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
src/errors/wrap.go