os: delete os.EINVAL and so on
The set of errors forwarded by the os package varied with system and
was therefore non-portable.
Three helpers added for portable error checking: IsExist, IsNotExist, and IsPermission.
One or two more may need to come, but let's keep the set very small to discourage
thinking about errors that way.
R=mikioh.mikioh, gustavo, r, rsc
CC=golang-dev
https://golang.org/cl/5672047
diff --git a/src/pkg/os/exec/lp_unix.go b/src/pkg/os/exec/lp_unix.go
index 2d3a919..2163221 100644
--- a/src/pkg/os/exec/lp_unix.go
+++ b/src/pkg/os/exec/lp_unix.go
@@ -23,7 +23,7 @@
if m := d.Mode(); !m.IsDir() && m&0111 != 0 {
return nil
}
- return os.EPERM
+ return os.ErrPermission
}
// LookPath searches for an executable binary named file
diff --git a/src/pkg/os/exec/lp_windows.go b/src/pkg/os/exec/lp_windows.go
index b7efcd6..d8351d7 100644
--- a/src/pkg/os/exec/lp_windows.go
+++ b/src/pkg/os/exec/lp_windows.go
@@ -19,7 +19,7 @@
return err
}
if d.IsDir() {
- return os.EPERM
+ return os.ErrPermission
}
return nil
}
@@ -39,7 +39,7 @@
return f, nil
}
}
- return ``, os.ENOENT
+ return ``, os.ErrNotExist
}
// LookPath searches for an executable binary named file