Standard library / os
os.SyscallError
Records a system call name and its underlying error, which is available via Unwrap. Use errors.Is to classify it. 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
type SyscallError struct { Syscall string Err error}Working Example
Example Snippetgo
package main
import ( "errors" "fmt" "os" "syscall")
func must(e error) { if e != nil { panic(e) }}func main() { e := &os.SyscallError{Syscall: "read", Err: syscall.EIO} fmt.Println(errors.Is(e, syscall.EIO))}