Standard library / os

os.SyscallError.Timeout()

Reports whether the underlying error indicates a timeout. It does not impose a deadline. Example intended for Linux/AMD64 with Go 1.23.2 in a disposable working directory; other platforms may differ. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (e *SyscallError) Timeout() bool

Return Value

bool

Reports whether the underlying error indicates a timeout.

Working Example

Example Snippetgo
package main
import (  "fmt"  "os")
func must(e error) {  if e != nil {    panic(e)  }}func main() {  e := &os.SyscallError{Syscall: "read", Err: os.ErrDeadlineExceeded}  fmt.Println(e.Timeout())}
Go Reference