Closed
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.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Accepted