Standard library / io/fs

fs.PathError.Error()

Formats operation, path and underlying error for diagnostics; avoid parsing the resulting string for error classification. Expected stdout: 'open x: file does not exist\n'.

Formal Syntax & Structure

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

Return Value

string

Formats operation, path and underlying error for diagnostics; avoid parsing the resulting string for error classification.

Working Example

Example Snippetgo
package main
import (  "fmt"  "io/fs")
func main() { e := &fs.PathError{Op: "open", Path: "x", Err: fs.ErrNotExist}; fmt.Println(e.Error()) }
Go Reference