memfs

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: MIT Imports: 7 Imported by: 0

README

go-memfs

An in-memory fs.FS implementation for Go.

Installation

go get github.com/spiretechnology/go-memfs

Example Usage

fs := memfs.FS{
    "foo.txt": memfs.File("Hello, world!"),
    "bar.txt": memfs.File("Goodbye, world!"),
    "foobar/baz.txt": memfs.File("Hello, again!"),
    "some/empty/dir": memfs.Dir{},
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dir

type Dir struct{}

Dir is a type of Entry that represents a directory with no contents.

func (Dir) ToEntry

func (f Dir) ToEntry(name string) fs.DirEntry

type Entry

type Entry interface {
	ToEntry(name string) fs.DirEntry
}

Entry is the interface that describes a file or directory.

type FS

type FS map[string]Entry

func (FS) Open

func (f FS) Open(name string) (fs.File, error)

func (FS) ReadDir

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

func (FS) Stat added in v1.1.0

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

type File

type File []byte

File is a type of Entry that represents a file.

func (File) ToEntry

func (f File) ToEntry(name string) fs.DirEntry

Jump to

Keyboard shortcuts

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