aboutsummaryrefslogtreecommitdiff
path: root/src/errors/wrap_test.go
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2024-04-03 11:50:36 +0200
committerGopher Robot <gobot@golang.org>2024-04-03 22:49:49 +0000
commitaf43932c20d5b59cdffca45406754dbccbb46dfa (patch)
tree968e7d230be3a65bb690d1252d4e0459ed4d24db /src/errors/wrap_test.go
parenta4440e3d236dc2ca65851c39a51958cc1b3c03fb (diff)
downloadgo-af43932c20d5b59cdffca45406754dbccbb46dfa.tar.xz
errors: return early for Is(nil, ...)
If err is nil it wouldn't match any given target error except for nil, so we can return early to speed up cases where Is is used without a preceding err != nil check. Change-Id: Ib33cff50453fe070f06871ce8074694c81ab787b Reviewed-on: https://go-review.googlesource.com/c/go/+/576015 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/errors/wrap_test.go')
-rw-r--r--src/errors/wrap_test.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/errors/wrap_test.go b/src/errors/wrap_test.go
index 0a7bc5d16a..58ed95fd9a 100644
--- a/src/errors/wrap_test.go
+++ b/src/errors/wrap_test.go
@@ -30,6 +30,7 @@ func TestIs(t *testing.T) {
match bool
}{
{nil, nil, true},
+ {nil, err1, false},
{err1, nil, false},
{err1, err1, true},
{erra, err1, true},