os: add IsTimeout function

Fixes build error: undefined: os.IsTimeout

Signed-off-by: Christian Stewart <christian@paral.in>
This commit is contained in:
Christian Stewart
2023-03-03 22:59:59 -08:00
committed by Ron Evans
parent 57ecf1acdc
commit 930255ff46
+5
View File
@@ -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