diff --git a/file.go b/file.go index f382137..13a23dc 100644 --- a/file.go +++ b/file.go @@ -5,6 +5,7 @@ package winio import ( "errors" "io" + "os" "runtime" "sync" "sync/atomic" @@ -31,6 +32,10 @@ func (*timeoutError) Error() string { return "i/o timeout" } func (*timeoutError) Timeout() bool { return true } func (*timeoutError) Temporary() bool { return true } +// Unwrap returns os.ErrDeadlineExceeded so that errors.Is(err, os.ErrDeadlineExceeded) +// returns true for ErrTimeout, enabling interoperability with the standard library. +func (*timeoutError) Unwrap() error { return os.ErrDeadlineExceeded } + type timeoutChan chan struct{} var ioInitOnce sync.Once