assetfs

package
v1.25.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 20 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateEmbedBindata added in v1.25.0

func GenerateEmbedBindata(fsRootPath, outputFile string) error

func NewEmbeddedFS added in v1.25.0

func NewEmbeddedFS(data []byte) fs.ReadDirFS

Types

type EmbeddedCompressedFile added in v1.25.0

type EmbeddedCompressedFile struct {
	EmbeddedFileBase
	// contains filtered or unexported fields
}

func (*EmbeddedCompressedFile) Close added in v1.25.0

func (f *EmbeddedCompressedFile) Close() error

func (*EmbeddedCompressedFile) Read added in v1.25.0

func (f *EmbeddedCompressedFile) Read(p []byte) (n int, err error)

type EmbeddedFile added in v1.25.0

type EmbeddedFile interface {
	io.ReadSeeker
	fs.ReadDirFile
	ReadDir(n int) ([]fs.DirEntry, error)
}

type EmbeddedFileBase added in v1.25.0

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

func (*EmbeddedFileBase) ReadDir added in v1.25.0

func (f *EmbeddedFileBase) ReadDir(n int) ([]fs.DirEntry, error)

func (*EmbeddedFileBase) Seek added in v1.25.0

func (f *EmbeddedFileBase) Seek(offset int64, whence int) (int64, error)

func (*EmbeddedFileBase) Stat added in v1.25.0

func (f *EmbeddedFileBase) Stat() (fs.FileInfo, error)

type EmbeddedFileInfo added in v1.25.0

type EmbeddedFileInfo interface {
	fs.FileInfo
	fs.DirEntry
	GetGzipContent() ([]byte, bool)
}

type EmbeddedMeta added in v1.25.0

type EmbeddedMeta struct {
	Root *embeddedFileInfo
}

type EmbeddedOriginFile added in v1.25.0

type EmbeddedOriginFile struct {
	EmbeddedFileBase
}

func (*EmbeddedOriginFile) Close added in v1.25.0

func (f *EmbeddedOriginFile) Close() error

func (*EmbeddedOriginFile) Read added in v1.25.0

func (f *EmbeddedOriginFile) Read(p []byte) (n int, err error)

type Layer

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

Layer represents a layer in a layered asset file-system. It has a name and works like http.FileSystem

func Bindata

func Bindata(name string, fs fs.FS) *Layer

Bindata returns a new Layer with the given name, it serves files from the given bindata asset.

func Local

func Local(name, base string, sub ...string) *Layer

Local returns a new Layer with the given name, it serves files from the given local path.

func (*Layer) Name

func (l *Layer) Name() string

func (*Layer) Open

func (l *Layer) Open(name string) (http.File, error)

Open opens the named file. The caller is responsible for closing the file.

type LayeredFS

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

LayeredFS is a layered asset file-system. It works like http.FileSystem, but it can have multiple layers. The first layer is the top layer, and it will be used first. If the file is not found in the top layer, it will be searched in the next layer.

func Layered

func Layered(layers ...*Layer) *LayeredFS

Layered returns a new LayeredFS with the given layers. The first layer is the top layer.

func (*LayeredFS) GetFileLayerName

func (l *LayeredFS) GetFileLayerName(elems ...string) string

GetFileLayerName returns the name of the first-seen layer that contains the given file.

func (*LayeredFS) ListAllFiles

func (l *LayeredFS) ListAllFiles(name string, fileMode ...bool) ([]string, error)

ListAllFiles returns files/directories in the given directory, including subdirectories, recursively. The fileMode controls the returned files: * omitted: all files and directories will be returned. * true: only files will be returned. * false: only directories will be returned. The returned files are sorted by name.

func (*LayeredFS) ListFiles

func (l *LayeredFS) ListFiles(name string, fileMode ...bool) ([]string, error)

ListFiles lists files/directories in the given directory. The fileMode controls the returned files. * omitted: all files and directories will be returned. * true: only files will be returned. * false: only directories will be returned. The returned files are sorted by name.

func (*LayeredFS) Open

func (l *LayeredFS) Open(name string) (http.File, error)

Open opens the named file. The caller is responsible for closing the file.

func (*LayeredFS) ReadFile

func (l *LayeredFS) ReadFile(elems ...string) ([]byte, error)

ReadFile reads the named file.

func (*LayeredFS) ReadLayeredFile

func (l *LayeredFS) ReadLayeredFile(elems ...string) ([]byte, string, error)

ReadLayeredFile reads the named file, and returns the layer name.

func (*LayeredFS) WatchLocalChanges

func (l *LayeredFS) WatchLocalChanges(ctx context.Context, callback func())

WatchLocalChanges watches local changes in the file-system. It's used to help to reload assets when the local file-system changes.

Jump to

Keyboard shortcuts

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