memfs

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package memfs is an in-memory file system for tests of code that reads through meaning.FS. Paths are slash-separated; a leading slash is ignored.

Index

Constants

This section is empty.

Variables

View Source
var ErrTooLarge = errors.New("the file is larger than what is read of it")

ErrTooLarge is the error of ReadFileMax for a file of more than max bytes (it stands for meaning.ErrTooLarge, which this package cannot import).

Functions

This section is empty.

Types

type FS

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

FS holds files in memory.

func New

func New(files map[string]string, symlinks ...string) FS

New returns a file system holding the given files (path to content). The paths named in symlinks are symbolic links instead of regular files.

func (FS) ReadDir

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

ReadDir lists a directory, sorted by name.

func (FS) ReadFile

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

ReadFile returns the content of a file.

func (FS) ReadFileMax

func (m FS) ReadFileMax(name string, max int64) ([]byte, error)

ReadFileMax returns the content of a file of at most max bytes.

func (FS) Stat

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

Stat describes a file or directory.

Jump to

Keyboard shortcuts

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