Documentation ¶
Index ¶
Constants ¶
const (
DefaultFilesystemKey = "default"
)
Variables ¶
var DefaultFilesystem = &wrapperFs{key: DefaultFilesystemKey, FS: OsFS{}}
Functions ¶
This section is empty.
Types ¶
type FilesystemMap ¶
type FilesystemMap struct {
// contains filtered or unexported fields
}
FilesystemMap stores a map of filesystems the empty key will be overwritten to be the default key it includes a default filesystem, based off the os fs
func (*FilesystemMap) Default ¶
func (f *FilesystemMap) Default() fs.FS
Default will get the default filesystem in the filesystem map
func (*FilesystemMap) Get ¶
func (f *FilesystemMap) Get(k string) (v fs.FS, ok bool)
Get will get a filesystem with a given key
func (*FilesystemMap) Register ¶
func (f *FilesystemMap) Register(k string, v fs.FS)
Register will add the filesystem with key to later be retrieved A call with a nil fs will call unregister, ensuring that a call to Default() will never be nil
func (*FilesystemMap) Unregister ¶
func (f *FilesystemMap) Unregister(k string)
Unregister will remove the filesystem with key from the filesystem map if the key is the default key, it will set the default to the osFS instead of deleting it modules should call this on cleanup to be safe
type OsFS ¶
type OsFS struct{}
OsFS is a simple fs.FS implementation that uses the local file system. (We do not use os.DirFS because we do our own rooting or path prefixing without being constrained to a single root folder. The standard os.DirFS implementation is problematic since roots can be dynamic in our application.)
OsFS also implements fs.StatFS, fs.GlobFS, fs.ReadDirFS, and fs.ReadFileFS.