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: Remove documentation does not explain how it differs from RemoveAll #26507
What version of Go are you using (
Not a helpful comment: I wish that "rm" just removed an empty directory, that I didn't need to use "rmdir".
More helpful: "rm" and "rmdir" both use the underlying "unlink" system call on Unix; the different experiences they provide is part of their design. The OS just has one system call, which we wrap with
Consider permissions: Do we need to add a paragraph to every
I have no idea what Windows does here, but I know that
It might be OK to say,
adding the parenthetical. I would protest at doing more than that.
I think the distinction I'd draw with the permissions case is that the permissions behavior is fairly consistent in general. Directory removal has been fairly inconsistent bbetween programming languages. Users who aren't used to thinking at the syscall level are quite possibly used to "drag file to trash" or something similar, and may not expect os.Remove() to fail even on non-empty directories; users who are used to thinking in syscalls may think "directories need a different remove operation than files". My first thought was that if a thing removes a file-or-directory, it presumably removes directories recursively; I only guessed otherwise because the adjacent RemoveAll implied a distinction.
I agree that the (empty) qualifier is enough to make the intent unambiguous. (But in fact, I wasn't even 100% sure that this was the intent, as opposed to how it happened to work on existing targets.)
(And I agree about rm/rmdir, but I think we may be >45 years late to win that one.)