]> Cypherpunks repositories - gostls13.git/commit
os: make errors.Is work with ErrPermission et al.
authorDamien Neil <dneil@google.com>
Tue, 19 Feb 2019 21:03:55 +0000 (13:03 -0800)
committerDamien Neil <dneil@google.com>
Wed, 20 Mar 2019 16:02:01 +0000 (16:02 +0000)
commita919b760378343a211719991a9e0b1b819ac9f3d
tree8dcfc732a1859575e762bafd5baf714ae7ee4af3
parentaf7b7571c4575748cf8cb2ffe683e97286666e1c
os: make errors.Is work with ErrPermission et al.

As proposed in Issue #29934, update errors produced by the os package to
work with errors.Is sentinel tests. For example,
errors.Is(err, os.ErrPermission) is equivalent to os.IsPermission(err)
with added unwrapping support.

Move the definition for os.ErrPermission and others into the syscall
package. Add an Is method to syscall.Errno and others. Add an Unwrap
method to os.PathError and others.

Updates #30322
Updates #29934

Change-Id: I95727d26c18a5354c720de316dff0bffc04dd926
Reviewed-on: https://go-review.googlesource.com/c/go/+/163058
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
14 files changed:
src/fmt/errors_test.go
src/go/build/deps_test.go
src/internal/oserror/errors.go [new file with mode: 0644]
src/os/error.go
src/os/error_plan9.go [deleted file]
src/os/error_test.go
src/os/error_unix.go [deleted file]
src/os/error_windows.go [deleted file]
src/os/file.go
src/syscall/syscall_js.go
src/syscall/syscall_nacl.go
src/syscall/syscall_plan9.go
src/syscall/syscall_unix.go
src/syscall/syscall_windows.go