memfs

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

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

FS represents a file system in memory.

func New

func New(dirs map[string][]string, files map[string]string) *FS

New creates a file system instance.

func SingleFile

func SingleFile(dir string, fname string, data string) *FS

SingleFile creates a file system that only contains a single file.

func TwoFiles

func TwoFiles(dir string, fname1, data1, fname2, data2 string) *FS

TwoFiles creates a file system that contains two files.

func (*FS) Abs added in v1.2.0

func (p *FS) Abs(path string) (string, error)

func (*FS) Base added in v1.1.10

func (p *FS) Base(filename string) string

Base returns the last element of path. Trailing slashes are removed before extracting the last element. If the path is empty, Base returns ".". If the path consists entirely of slashes, Base returns "/".

func (*FS) Join

func (p *FS) Join(elem ...string) string

Join joins any number of path elements into a single path, separating them with slashes. Empty elements are ignored. The result is Cleaned. However, if the argument list is empty or all its elements are empty, Join returns an empty string.

func (*FS) ReadDir

func (p *FS) ReadDir(dirname string) ([]fs.DirEntry, error)

ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename.

func (*FS) ReadFile

func (p *FS) ReadFile(filename string) ([]byte, error)

ReadFile reads the file named by filename and returns the contents. A successful call returns err == nil, not err == EOF. Because ReadFile reads the whole file, it does not treat an EOF from Read as an error to be reported.

type FileFS

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

func File

func File(filename string, src interface{}) (f *FileFS, err error)

func (*FileFS) Abs added in v1.2.0

func (p *FileFS) Abs(path string) (string, error)

func (*FileFS) Base added in v1.1.10

func (p *FileFS) Base(filename string) string

func (*FileFS) Join

func (p *FileFS) Join(elem ...string) string

func (*FileFS) ReadDir

func (p *FileFS) ReadDir(dirname string) ([]fs.DirEntry, error)

func (*FileFS) ReadFile

func (p *FileFS) ReadFile(filename string) ([]byte, error)

Jump to

Keyboard shortcuts

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