Documentation
¶
Index ¶
- type FS
- func (m *FS) CopyDir(src, dst string) error
- func (m *FS) CopyFilesUnder(dir string) error
- func (m *FS) Filter(skippedFiles []string) (*FS, error)
- func (m *FS) FilterFunc(fn func(path string, d fs.DirEntry) (bool, error)) (*FS, error)
- 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) Stat(name string) (fs.FileInfo, error)
- func (m *FS) Sub(dir string) (fs.FS, error)
- func (m *FS) WriteFile(path, underlyingPath string) error
- func (m *FS) WriteVirtualFile(path string, data []byte, mode fs.FileMode) error
- type Option
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 (*FS) CopyDir ¶ added in v0.63.0
CopyDir copies a directory from the local filesystem into the in-memory filesystem. This function works similarly to the Unix command "cp -r src dst", recursively copying the entire directory structure from the source to the destination.
The function: 1. Walks through all files and subdirectories in the source directory 2. Recreates the directory structure in the in-memory filesystem 3. Copies all files while preserving their relative paths
Parameters:
- src: The source directory path in the local filesystem
- dst: The destination directory path in the in-memory filesystem
For example, if src is "/tmp/data" and dst is "app/", then: - A file at "/tmp/data/settings.json" will be copied to "app/data/settings.json" - A file at "/tmp/data/subdir/config.yaml" will be copied to "app/data/subdir/config.yaml"
func (*FS) CopyFilesUnder ¶
TODO(knqyf263): Remove this method and replace with CopyDir
func (*FS) FilterFunc ¶ added in v0.41.0
func (*FS) Glob ¶
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 ¶
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 ¶
RemoveAll deletes a file or directory and any children if present from the filesystem