Documentation ¶
Index ¶
- type MountedFS
- func (f MountedFS) Mount(name string, fs fs.FS)
- func (f MountedFS) Open(name string) (fs.File, error)
- func (f MountedFS) OpenFile(name string, flag int, perm fs.FileMode) (writefs.FileWriter, error)
- func (f MountedFS) ReadFile(name string) ([]byte, error)
- func (f MountedFS) Stat(name string) (fs.FileInfo, error)
- func (f MountedFS) Sub(dir string) (fs.FS, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MountedFS ¶
MountedFS is a `fs.FS` implementation that allows to group together multiple named filesystems and access them as if they are mounted under a virtual root directory, whose entries are names as the filesystems theirself.
mfs := MountedFS{ "mem1": fstest.MapFS{ "adir/afile": &fstest.MapFile{Data: data}, }, "mem2": fstest.MapFS{ "adir2/afile2": &fstest.MapFile{Data: data}, }, } mfs.Open("mem1/adir/afile") // returns adir/afile from mem1 fs mfs.Open("mem2/adir2/afile2") // returns adir2/afile2 from mem2 fs mfs.Open("mem2") // returns root of mem2 mfs.Open(".") // returns a virtual ReadDirFile containing // an entry for mem1 and one for mem2
MountedFS implements: * fs.ReadFileFS * fs.StatFS * fs.SubFS * writefs.WriteFS
Click to show internal directories.
Click to hide internal directories.