os.Stat: returned error on nonexistent path did not satisfy IsNotExist

Add direct test for the problem to make the fix commit clearer.

Noticed while implementing MkdirTemp on mac; the upstream tests for MkdirTemp fail without this.
This commit is contained in:
Dan Kegel
2021-12-12 15:16:52 -08:00
committed by Ron Evans
parent 1f6b4a5e7b
commit d30f8b6ed6
2 changed files with 13 additions and 2 deletions
+2 -2
View File
@@ -19,7 +19,7 @@ func (f *File) Sync() error {
func statNolog(name string) (FileInfo, error) {
var fs fileStat
err := ignoringEINTR(func() error {
return syscall.Stat(name, &fs.sys)
return handleSyscallError(syscall.Stat(name, &fs.sys))
})
if err != nil {
return nil, &PathError{Op: "stat", Path: name, Err: err}
@@ -32,7 +32,7 @@ func statNolog(name string) (FileInfo, error) {
func lstatNolog(name string) (FileInfo, error) {
var fs fileStat
err := ignoringEINTR(func() error {
return syscall.Lstat(name, &fs.sys)
return handleSyscallError(syscall.Lstat(name, &fs.sys))
})
if err != nil {
return nil, &PathError{Op: "lstat", Path: name, Err: err}