Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
os: Readdir fails, if one of the files cannot be accessed #11235
If directory contains file that cannot be accessed (if lstat fails), f.Readdir fails with an error.
Error can be reproduced using custom FUSE driver.
Bash fails to show info for that dir but still lists other files.
Readdir fails with lstat permission denied (http://play.golang.org/p/G_yZ94rkRs).
Readdirnames works fine (http://play.golang.org/p/WY-uBxCjpd).
This is working as designed and documented: "In this case, if Readdir succeeds (reads all the way to the end of the directory), it returns the slice and a nil error. If it encounters an error before the end of the directory, Readdir returns the FileInfo read until that point and a non-nil error."
I think you already found the answer: use Readdirnames.