Standard library / os

os.IsTimeout()

Legacy timeout predicate; timeout meaning depends on the underlying error. For deadline errors prefer errors.Is with os.ErrDeadlineExceeded. Example uses a disposable temporary workspace. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func IsTimeout(err error) bool

Parameters & Attributes

NameTypeDescription
errerrorError to classify.

Return Value

bool

Legacy timeout predicate; timeout meaning depends on the underlying error.

Working Example

Example Snippetgo
package main
import (  "fmt"  "os")
func check(e error) {  if e != nil {    panic(e)  }}func workspace() func() {  root, e := os.MkdirTemp("", "bytemind-go-")  check(e)  old, e := os.Getwd()  check(e)  check(os.Chdir(root))  return func() { check(os.Chdir(old)); check(os.RemoveAll(root)) }}func main() { defer workspace()(); fmt.Println(os.IsTimeout(os.ErrDeadlineExceeded)) }
Go Reference