From 930255ff46c96584e1ad91d9d55bbeccf851bcd8 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Fri, 3 Mar 2023 22:59:59 -0800 Subject: [PATCH] os: add IsTimeout function Fixes build error: undefined: os.IsTimeout Signed-off-by: Christian Stewart --- src/os/errors.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/os/errors.go b/src/os/errors.go index 74c77c90..23b738c9 100644 --- a/src/os/errors.go +++ b/src/os/errors.go @@ -92,6 +92,11 @@ func IsPermission(err error) bool { return underlyingErrorIs(err, ErrPermission) } +func IsTimeout(err error) bool { + terr, ok := underlyingError(err).(timeout) + return ok && terr.Timeout() +} + func underlyingErrorIs(err, target error) bool { // Note that this function is not errors.Is: // underlyingError only unwraps the specific error-wrapping types