Closed
Description
There is a change in behavior of os.RemoveAll
on tip compared to 1.11.2, on macOS (and Linux, BSDs), caused by CL 146020, in a specific scenario. I can't definitively say whether this change should considered a bug/regression, or if it's a normal intentional new behavior, so marking as NeedsDecision.
Prior to CL 146020, it was possible to use os.RemoveAll
to remove an empty directory without read permissions, because its code had a "Simple case" as the first thing it tried:
func RemoveAll(path string) error {
// Simple case: if Remove works, we're done.
err := Remove(path)
if err == nil || IsNotExist(err) {
return nil
}
...
So the Go program https://play.golang.org/p/68OMhP1VS7G printed temp file was removed: true
.
The new os.RemoveAll
code after CL 146020 tries to read the directory before performing the "simple case", and returns a permission error instead:
$ go run .
temp file was removed: true
$ gotip run .
2018/12/11 16:14:39 os.RemoveAll: permission denied
exit status 1