io/fs: document whether []byte from ReadFile is (un)safe to modify #45186
Labels
Documentation
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Here are the current docs for fs.ReadFileFS's ReadFile method:
This does not specify whether the returned
[]byte
must be safe to modify or not. I can see the argument for either. It's better for efficiency if it is unsafe and better for safety if it is safe. I think this needs to be documented because Hyrum's Law/XKCD 1172 ensures that very soon someReadFileFS
implementation will be made more efficient by returning an unmodifiable backing store[]byte
and some clients will be made more efficient by modifying the return value offs.ReadFile
, which will lead to bugs.The text was updated successfully, but these errors were encountered: