struct@ FS
struct@ FS {
fn open(string) os.File
}Purpose
Method set of fs.FS / fs.File (constraints only; no interface values).
Parameters
openfn open(string) os.File- Method on `FS`: open.
API
#io/fsDirectory-tree view. Implementation is concrete os.DirFS; package functions take &os.DirFS. valid_path checks unrooted slash paths.
struct@ FSstruct@ FS {
fn open(string) os.File
}Method set of fs.FS / fs.File (constraints only; no interface values).
open fn open(string) os.File(FS) openfn open(string) os.FileMethod on `FS`: open.
self Selfstring stringos.File — a value of this type
struct@ Filestruct@ File {
fn read(int) string
fn close() int
}Method-set constraint `File`. Implementing types must provide the methods below. Not an interface value.
read fn read(int) stringclose fn close() int(File) readfn read(int) stringMethod on `File`: read up to max bytes.
self Selfint intstring — result string
(File) closefn close() intMethod on `File`: close the resource.
self Selfint — a value of this type
struct DirEntrypub struct DirEntry {
pub name string
pub is_dir bool
}FileInfo is the language builtin (: size / is_dir / mode), same as os.Stat — fs.FileInfo.Name is path.base of the lookup name.
name stringis_dir boolvalid_pathpub fn valid_path(name &string) boolvalid_path is fs.ValidPath: unrooted slash-separated name; "." is the only allowed "." / empty / ".." exception (the FS root).
name &stringbool — true or false
read_filepub fn read_file(fsys &os.DirFS, name string) stringRead file. Throws on failure.
fsys &os.DirFSname stringstring — result string
read_dirpub fn read_dir(fsys &os.DirFS, name string) []DirEntryRead directory. Throws on failure.
fsys &os.DirFSname string[]DirEntry — slice result
statpub fn stat(fsys &os.DirFS, name string) FileInfoRead metadata. Throws on failure.
fsys &os.DirFSname stringFileInfo — a value of this type
subpub fn sub(fsys &os.DirFS, dir string) os.DirFSSubtract. Throws on failure.
fsys &os.DirFSdir stringos.DirFS — a value of this type