diff options
| author | Julien Cretel <jub0bsinthecloud@gmail.com> | 2025-10-01 20:08:18 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-10-13 10:12:48 -0700 |
| commit | 6bcd97d9f4386528aa85eb3cc27da0ed902de870 (patch) | |
| tree | 54acec806440b95e7afc493d42b0b095fdaee1a5 /src/testing | |
| parent | 1cd71689f2ed8f07031a0cc58fc3586ca501839f (diff) | |
| download | go-6bcd97d9f4386528aa85eb3cc27da0ed902de870.tar.xz | |
all: replace calls to errors.As with errors.AsType
This change replaces most occurrences (in code as well as in comments) of
errors.As with errors.AsType. It leaves the errors package and vendored
code untouched.
Change-Id: I3bde73f318a0b408bdb8f5a251494af15a13118a
GitHub-Last-Rev: 8aaaa36a5a12d2a6a90c6d51680464e1a3115139
GitHub-Pull-Request: golang/go#75698
Reviewed-on: https://go-review.googlesource.com/c/go/+/708495
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/testing')
| -rw-r--r-- | src/testing/fstest/testfs.go | 2 | ||||
| -rw-r--r-- | src/testing/fstest/testfs_test.go | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/testing/fstest/testfs.go b/src/testing/fstest/testfs.go index 1fb84b8928..72830a09a7 100644 --- a/src/testing/fstest/testfs.go +++ b/src/testing/fstest/testfs.go @@ -29,7 +29,7 @@ import ( // The contents of fsys must not change concurrently with TestFS. // // If TestFS finds any misbehaviors, it returns either the first error or a -// list of errors. Use [errors.Is] or [errors.As] to inspect. +// list of errors. Use [errors.Is] or [errors.AsType] to inspect. // // Typical usage inside a test is: // diff --git a/src/testing/fstest/testfs_test.go b/src/testing/fstest/testfs_test.go index d6d6d89b89..e3d7f1ab44 100644 --- a/src/testing/fstest/testfs_test.go +++ b/src/testing/fstest/testfs_test.go @@ -105,8 +105,12 @@ func TestTestFSWrappedErrors(t *testing.T) { // TestFS is expected to return a list of errors. // Enforce that the list can be extracted for browsing. - var errs interface{ Unwrap() []error } - if !errors.As(err, &errs) { + type wrapper interface{ + error + Unwrap() []error + } + errs, ok := errors.AsType[wrapper](err) + if !ok { t.Errorf("caller should be able to extract the errors as a list: %#v", err) } else { for _, err := range errs.Unwrap() { |
