Documentation ¶
Index ¶
- type FS
- func (m *FS) Glob(pattern string) ([]string, error)
- func (m *FS) MkdirAll(path string, perm fs.FileMode) error
- func (m *FS) Open(name string) (fs.File, error)
- func (m *FS) ReadDir(name string) ([]fs.DirEntry, error)
- func (m *FS) ReadFile(name string) ([]byte, error)
- func (m *FS) Remove(path string) error
- func (m *FS) RemoveAll(path string) error
- func (m *FS) SetModified(name string, modified time.Time) error
- func (m *FS) SetSys(name string, sys interface{}) error
- func (m *FS) Stat(name string) (fs.FileInfo, error)
- func (m *FS) Sub(dir string) (fs.FS, error)
- func (m *FS) WriteFile(path string, data []byte, perm fs.FileMode) error
- func (m *FS) WriteLazyFile(path string, opener LazyOpener, perm fs.FileMode) error
- type LazyOpener
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
FS is an in-memory filesystem
func CloneFS ¶ added in v1.3.0
CloneFS allows you to take on fs.FS and wrap it in an fs that is writable
func (*FS) Glob ¶ added in v1.0.0
Glob returns the names of all files matching pattern or nil if there is no matching file. The syntax of patterns is the same as in Match. The pattern may describe hierarchical names such as /usr/*/bin/ed (assuming the Separator is '/').
Glob ignores file system errors such as I/O errors reading directories. The only possible returned error is ErrBadPattern, when pattern is malformed.
func (*FS) MkdirAll ¶
MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil.
func (*FS) ReadDir ¶
ReadDir reads the named directory and returns a list of directory entries sorted by filename.
func (*FS) ReadFile ¶ added in v1.0.0
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.)
The caller is permitted to modify the returned byte slice. This method should return a copy of the underlying data.
func (*FS) RemoveAll ¶ added in v1.4.0
RemoveAll deletes a file or directory and any children if present from the filesystem
func (*FS) SetModified ¶ added in v1.5.0
SetModified set modified time to file or directory
func (*FS) WriteFile ¶
WriteFile writes the specified bytes to the named file. If the file exists, it will be overwritten.
func (*FS) WriteLazyFile ¶ added in v1.1.0
WriteLazyFile creates (or overwrites) the named file. The contents of the file are not set at this time, but are read on-demand later using the provided LazyOpener.
type LazyOpener ¶ added in v1.1.0
LazyOpener provides an io.Reader that can be used to access the content of a file, whatever the actual storage medium. If the LazyOpener returns an io.ReadCloser, it will be closed after each read.