os: Remove documentation does not explain how it differs from RemoveAll #26507
Labels
Documentation
Issues describing a change to documentation.
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
What version of Go are you using (
go version
)?1.10
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?N/A (documentation)
What did you do?
Read documentation.
What did you expect to see?
A description of what os.Remove does that might differ from os.RemoveAll. :)
What did you see instead?
The blank assertion that os.Remove "removes a file".
ISO C's
remove
will remove a file or directory, but fail if the directory is empty. On the other hand,rm
will remove only files, if not given the-r
flag, and you needrmdir
to remove a directory. I have heard horror stories about filesystems where you could remove a directory that wasn't empty, and nightmarish things occurred. (I hope this isn't real.)My point is: I think it would be good for the docs for
os.Remove
to explicitly state behavior for likely edge cases, such as "can remove both files and directories" or "will not remove directories that have other contents." A quick straw poll revealed at least one person who assumed it would definitely not work on empty directories, and I suspect there are people out there assuming it will remove directories even if they are empty (probably recursively). A sentence outlining the intended behavior would reduce confusion.The text was updated successfully, but these errors were encountered: