From 83cfaa298f3169f3f9da8efdaccd64a2b2aa5a15 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 13 Nov 2020 15:45:34 +0100 Subject: [PATCH] windows: 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, windows.ERROR_PROC_NOT_FOUND) { ... } DLLError already was wrapping the underlying Errno error, but never got the Go 1.13 helper method. Update golang/go#42584 Change-Id: Ib916ddd55a2de29f988edaaf82f2ae0ce1b18e3b Reviewed-on: https://go-review.googlesource.com/c/sys/+/269937 Trust: Jason A. Donenfeld Run-TryBot: Jason A. Donenfeld TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- windows/dll_windows.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/windows/dll_windows.go b/windows/dll_windows.go index 82076fb7..9cd147b7 100644 --- a/windows/dll_windows.go +++ b/windows/dll_windows.go @@ -32,6 +32,8 @@ type DLLError struct { func (e *DLLError) Error() string { return e.Msg } +func (e *DLLError) Unwrap() error { return e.Err } + // A DLL implements access to a single DLL. type DLL struct { Name string