-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Closed
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
Here are the current docs for fs.ReadFileFS's ReadFile method:
// ReadFile reads the named file and returns its contents.
// A successful call returns a nil error, not io.EOF.
// (Because ReadFile reads the whole file, the expected EOF
// from the final Read is not treated as an error to be reported.)
ReadFile(name string) ([]byte, error)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 some ReadFileFS 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 of fs.ReadFile, which will lead to bugs.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.