-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposalProposal-Accepted
Milestone
Description
I propose adding ReadFile
and WriteFile
methods to *os.Root
:
package os
// ReadFile reads the named file in the root and returns the contents.
// See [ReadFile] for more details.
func (r *Root) ReadFile(name string) ([]byte, error)
// WriteFile writes data to the named file in the root, creating it if necessary.
// See [WriteFile] for more details.
func (r *Root) WriteFile(name string, data []byte, perm FileMode) error
These are purely convenience functions (as are os.ReadFile
and os.WriteFile
). I propose adding them because:
os.ReadFile
andos.WriteFile
are very convenient convenience functions, and it's a shame not to have an equivalent that works withos.Root
.- The
io/fs
package not only includes aReadFile
convenience function, it includes aReadFileFS
variant ofFS
containing aReadFile
method. I think that points at this being something we consider core filesystem functionality.
AndrewHarrisSPU, jaloren, tklauser, krhubert, irsl and 2 more
Metadata
Metadata
Assignees
Labels
LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposalProposal-Accepted
Type
Projects
Status
Accepted