Standard library / io/fs
fs.PathError.Unwrap()
Returns the underlying error, enabling errors.Is and errors.As traversal. Expected stdout: 'true true\n'.
Formal Syntax & Structure
go syntaxgo
func (e *PathError) Unwrap() errorReturn Value
error
Returns the underlying error, enabling errors.Is and errors.As traversal.
Working Example
Example Snippetgo
package main
import ( "errors" "fmt" "io/fs")
func main() { e := &fs.PathError{Op: "open", Path: "x", Err: fs.ErrNotExist} fmt.Println(e.Unwrap() == fs.ErrNotExist, errors.Is(e, fs.ErrNotExist))}