packageos// PathError records an error and the operation and file path that caused it.typePathErrorstruct { Op string Path string Err error}func (e *PathError) Error() string {return e.Op +" "+ e.Path +": "+ e.Err.Error()}
import ("errors""syscall")var ErrNotExist = errors.New("file does not exist")// IsNotExist returns a boolean indicating whether the error is known to// report that a file or directory does not exist. It is satisfied by// ErrNotExist as well as some syscall errors.funcIsNotExist(err error) bool {if pe, ok := err.(*PathError); ok { err = pe.Err }return err == syscall.ENOENT || err == ErrNotExist}