From: Jason A. Donenfeld Date: Fri, 13 Nov 2020 14:48:05 +0000 (+0100) Subject: syscall: add DLLError.Unwrap function X-Git-Tag: go1.16beta1~175 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f7342596daa892400e91a407cac5843bc43dcdd0;p=gostls13.git syscall: add DLLError.Unwrap function Because we're expecting for future functions to be unavailable, we should add an Unwrap() function to the DLLError struct, so that people can test for this situation easily via: if errors.Is(err, syscall.ERROR_PROC_NOT_FOUND) { ... } DLLError already was wrapping the underlying Errno error, but never got the Go 1.13 helper method. Fixes golang/go#42584 Change-Id: I0f32a5146946b1b37a30897ba825a56faefc792c Reviewed-on: https://go-review.googlesource.com/c/go/+/269761 Run-TryBot: Jason A. Donenfeld TryBot-Result: Go Bot Reviewed-by: Alex Brainman Trust: Alex Brainman Trust: Jason A. Donenfeld --- diff --git a/doc/go1.16.html b/doc/go1.16.html index a2f39893be..92cadff713 100644 --- a/doc/go1.16.html +++ b/doc/go1.16.html @@ -501,6 +501,10 @@ Do not send CLs removing the interior tags from such phrases.

SysProcAttr on Windows has a new NoInheritHandles field that disables inheriting handles when creating a new process.

+ +

+ DLLError on Windows now has an Unwrap function for unwrapping its underlying error. +

diff --git a/src/syscall/dll_windows.go b/src/syscall/dll_windows.go index c54feec56a..d99da00089 100644 --- a/src/syscall/dll_windows.go +++ b/src/syscall/dll_windows.go @@ -20,6 +20,8 @@ type DLLError struct { func (e *DLLError) Error() string { return e.Msg } +func (e *DLLError) Unwrap() error { return e.Err } + // Implemented in ../runtime/syscall_windows.go. func Syscall(trap, nargs, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)