Standard library / os

os.SyscallError.Error()

Formats the operation and underlying error as diagnostic text. Do not parse it for program logic. Example intended for Linux/AMD64 with Go 1.23.2 in a disposable working directory; other platforms may differ. Expected stdout: 'read: input/output error\n'.

Formal Syntax & Structure

go syntaxgo
func (e *SyscallError) Error() string

Return Value

string

Formats the operation and underlying error as diagnostic text.

Working Example

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