diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-24 15:03:27 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-25 21:47:29 +0100 |
commit | 7757c644bdc4ed0c7f150bd89889c4cbfc031b5d (patch) | |
tree | ce6836fdc9d14dacf6c8392d6193efed5b2c45c3 /updater | |
parent | updater,version: simplify code locations (diff) | |
download | wireguard-windows-7757c644bdc4ed0c7f150bd89889c4cbfc031b5d.tar.xz wireguard-windows-7757c644bdc4ed0c7f150bd89889c4cbfc031b5d.zip |
winhttp: use errors.As for unwrapping
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'updater')
-rw-r--r-- | updater/winhttp/winhttp.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/updater/winhttp/winhttp.go b/updater/winhttp/winhttp.go index 02be18a3..8c4201c0 100644 --- a/updater/winhttp/winhttp.go +++ b/updater/winhttp/winhttp.go @@ -6,13 +6,13 @@ package winhttp import ( + "errors" "fmt" "io" "runtime" "strconv" "strings" "sync/atomic" - "syscall" "unsafe" "golang.org/x/sys/windows" @@ -35,9 +35,10 @@ func convertError(err *error) { if *err == nil { return } - if se, ok := (*err).(syscall.Errno); ok { - if se > _WINHTTP_ERROR_BASE && se <= _WINHTTP_ERROR_LAST { - *err = Error(se) + var errno windows.Errno + if errors.As(*err, &errno) { + if errno > _WINHTTP_ERROR_BASE && errno <= _WINHTTP_ERROR_LAST { + *err = Error(errno) } } } |