os.RemoveAll silently failing to remove files

os.RemoveAll appears to have a bug: When a non-directory file path is supplied, then it silently fails to remove the file.

I would love to see os.RemoveAll become more flexible, so that it naturally supports operating over both a directory and a non-directory file. As a user, I often have to clean up both types of file paths, so it’s inconvenient having to manually specify the right one each time.

Note that the current documentation does not explicitly state that non-directory file paths are invalid. Nor does the function return an error when such is supplied.

os.RemoveAll silently fails only if path does not exist. Never have I ever experience problems removing folders nor files. What kind of files do you try to remove? Can you be more specific?

os.RemoveAll(path)

RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error).

path refers to both files or dirs

os.RemoveAll("/path/to/dir/or/file")

works just fine for me

I believe you.

Planning to test this a second time.

Would like the documentation for os.RemoveAll to clarify that. It doesn’t say so in very explicit terms.