Help us shape the future of Go! Take the 2026 Go Developer Survey

vfs

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package vfs is the file system a build reads from: the files a deck includes, its kinds and data files, slides.yaml or slides.hcl, and theme CSS.

The command reads the disk (OS). An editor reads its own buffers and the files it chose to hand over (Map), which keeps a deck that names /etc/passwd from reading it, and lets the same build run where there is no disk at all, in WebAssembly.

Names are the paths the build forms with path/filepath, relative to the working directory or absolute; they are not io/fs's slash-separated, unrooted names, since a deck says "../shared/kinds.yaml".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

type FS interface {
	// ReadFile returns a file's contents.
	ReadFile(name string) ([]byte, error)
	// Stat describes a file or a directory.
	Stat(name string) (fs.FileInfo, error)
	// ReadDir lists a directory, sorted by name.
	ReadDir(name string) ([]fs.DirEntry, error)
}

FS reads files.

func Or

func Or(f FS) FS

Or returns f, or OS when f is nil: a nil FS in an options struct means the disk.

type Map

type Map struct {
	// contains filtered or unexported fields
}

Map is a file system held in memory: file names to contents. A name that is not there reads as fs.ErrNotExist and is remembered, so that a caller that has the files elsewhere (an editor's workspace) can hand them over and build again.

Directories are implied by the files under them, and a directory can be declared empty with Dir. Map is safe for concurrent use.

func NewMap

func NewMap(files map[string][]byte) *Map

NewMap returns a Map holding files, keyed by cleaned name.

func (*Map) Dir

func (m *Map) Dir(name string)

Dir declares a directory, so that an empty one lists as empty instead of missing.

func (*Map) Listed

func (m *Map) Listed(name string)

Listed declares a file the caller has seen in a directory listing but not read: it lists and stats as a file (of unknown size, 0), and reading it records it as missing. A directory listing can then be handed over without the contents of every file in it.

func (*Map) Missing

func (m *Map) Missing() []string

Missing returns the names that were asked for and not found, sorted.

func (*Map) ReadDir

func (m *Map) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir lists the files and directories right under name.

func (*Map) ReadFile

func (m *Map) ReadFile(name string) ([]byte, error)

ReadFile returns a copy of a file's contents.

func (*Map) Stat

func (m *Map) Stat(name string) (fs.FileInfo, error)

Stat describes a file or a directory.

type OS

type OS struct{}

OS is the disk.

func (OS) ReadDir

func (OS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir calls os.ReadDir.

func (OS) ReadFile

func (OS) ReadFile(name string) ([]byte, error)

ReadFile calls os.ReadFile.

func (OS) Stat

func (OS) Stat(name string) (fs.FileInfo, error)

Stat calls os.Stat.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL