assetfs

package module
v0.0.0-...-e34a27c Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: MIT Imports: 26 Imported by: 16

README

AssetFS

Virtual Asset File System Library for Go Lang applications.

Get it

go get github.com/moisespsena-go/assetfs

Usage

See to go-assetfs-example project.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IS_DIR_ERROR = errors.New("Is directory.")
	IS_NS_ERROR  = errors.New("Is name space.")
)

Functions

func Data

func Data(info interface{ Reader() (io.ReadCloser, error) }) (b []byte, err error)

func DataS

func DataS(info interface{ Reader() (io.ReadCloser, error) }) (s string, err error)

func HttpStaticHandler

func HttpStaticHandler(fs assetfsapi.Interface) http.Handler

func IsGzip

func IsGzip(b []byte) bool

IsGzip returns true if the string is gzipped data

func MustData

func MustData(info interface{ Reader() (io.ReadCloser, error) }) (b []byte)

func MustDataS

func MustDataS(info interface{ Reader() (io.ReadCloser, error) }) (s string)

func NewGlobPattern

func NewGlobPattern(pattern string) assetfsapi.GlobPattern

pattern: \f Files, \r dirs

func NewSimpleGlobPattern

func NewSimpleGlobPattern(pattern string) assetfsapi.GlobPattern

pattern: \f Files, \r dirs

func ParseFileType

func ParseFileType(typ string) (t assetfsapi.FileType)

func RootPath

func RootPath(fs assetfsapi.Interface) string

func SaveExecutable

func SaveExecutable(assetName string, fs assetfsapi.Interface, dest string, force ...bool) (err error)

func SplitGlobPattern

func SplitGlobPattern(ipattern string) (dir, pattern string)

func StringifyFileInfo

func StringifyFileInfo(info assetfsapi.FileInfo) string

Types

type AssetFileSystem

type AssetFileSystem struct {
	assetfsapi.AssetGetterInterface
	assetfsapi.TraversableInterface
	local.LocalSourcesAttribute
	// contains filtered or unexported fields
}

AssetFileSystem AssetFS based on FileSystem

func NewAssetFileSystem

func NewAssetFileSystem() *AssetFileSystem

func (*AssetFileSystem) Compile

func (fs *AssetFileSystem) Compile() error

Compile compile assetfs

func (*AssetFileSystem) Dump

func (fs *AssetFileSystem) Dump(cb func(info assetfsapi.FileInfo) error, ignore ...func(pth string) bool) error

func (*AssetFileSystem) DumpC

func (fs *AssetFileSystem) DumpC(ctx context.Context, cb func(info assetfsapi.FileInfo) error, ignore ...func(pth string) bool) error

func (*AssetFileSystem) DumpFiles

func (fs *AssetFileSystem) DumpFiles(cb func(info assetfsapi.FileInfo) error) error

func (*AssetFileSystem) DumpFilesC

func (fs *AssetFileSystem) DumpFilesC(ctx context.Context, cb func(info assetfsapi.FileInfo) error) error

func (*AssetFileSystem) GetName

func (fs *AssetFileSystem) GetName() string

func (*AssetFileSystem) GetNameSpace

func (fs *AssetFileSystem) GetNameSpace(nameSpace string) (assetfsapi.NameSpacedInterface, error)

func (*AssetFileSystem) GetParent

func (fs *AssetFileSystem) GetParent() assetfsapi.Interface

func (*AssetFileSystem) GetPath

func (fs *AssetFileSystem) GetPath() string

func (*AssetFileSystem) GetPaths

func (fs *AssetFileSystem) GetPaths(recursive ...bool) (p []*fileutils.Dir)

func (*AssetFileSystem) NameSpace

func (fs *AssetFileSystem) NameSpace(nameSpace string) assetfsapi.NameSpacedInterface

NameSpace return namespaced filesystem

func (*AssetFileSystem) NameSpaceFS

func (fs *AssetFileSystem) NameSpaceFS(nameSpace string) *AssetFileSystem

NameSpace return namespaced filesystem

func (*AssetFileSystem) NameSpaces

func (fs *AssetFileSystem) NameSpaces() (items []assetfsapi.NameSpacedInterface)

func (*AssetFileSystem) OnPathRegister

func (fs *AssetFileSystem) OnPathRegister(cb ...assetfsapi.PathRegisterCallback)

func (*AssetFileSystem) PathsFrom

func (fs *AssetFileSystem) PathsFrom(ctx context.Context, pth string, cb func(pth string) error) (err error)

func (*AssetFileSystem) PrependPath

func (fs *AssetFileSystem) PrependPath(pth string, ignoreExists ...bool) error

PrependPath prepend path to view paths

func (*AssetFileSystem) PrependPathFS

func (fs *AssetFileSystem) PrependPathFS(pth string, ignoreExists ...bool) (assetfsapi.Interface, error)

PrependPath prepend path to view paths

func (*AssetFileSystem) ReadDir

func (fs *AssetFileSystem) ReadDir(dir string, cb assetfsapi.CbWalkInfoFunc, skipDir bool) (err error)

func (*AssetFileSystem) RegisterPath

func (fs *AssetFileSystem) RegisterPath(pth string, ignoreExists ...bool) error

RegisterPath register view paths

func (*AssetFileSystem) RegisterPathFS

func (fs *AssetFileSystem) RegisterPathFS(pth string, ignoreExists ...bool) (assetfsapi.Interface, error)

RegisterPath register view paths

func (*AssetFileSystem) RegisterPlugin

func (fs *AssetFileSystem) RegisterPlugin(plugins ...assetfsapi.Plugin)

func (*AssetFileSystem) ServeHTTP

func (fs *AssetFileSystem) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*AssetFileSystem) TreeNames

func (fs *AssetFileSystem) TreeNames(ctx context.Context, onlyFiles bool, ignore ...func(pth string) bool) (result []assetfsapi.FileInfo, err error)

type AssetGetter

type AssetGetter struct {
	AssetFunc     func(ctx context.Context, path string) ([]byte, error)
	AssetInfoFunc func(ctx context.Context, path string) (assetfsapi.FileInfo, error)
	// contains filtered or unexported fields
}

func (*AssetGetter) Asset

func (f *AssetGetter) Asset(path string) (asset assetfsapi.AssetInterface, err error)

func (*AssetGetter) AssetC

func (f *AssetGetter) AssetC(ctx context.Context, path string) (asset assetfsapi.AssetInterface, err error)

func (*AssetGetter) AssetInfo

func (f *AssetGetter) AssetInfo(path string) (assetfsapi.FileInfo, error)

func (*AssetGetter) AssetInfoC

func (f *AssetGetter) AssetInfoC(ctx context.Context, path string) (assetfsapi.FileInfo, error)

func (*AssetGetter) AssetReader

func (f *AssetGetter) AssetReader() assetfsapi.AssetReaderFunc

func (*AssetGetter) AssetReaderC

func (f *AssetGetter) AssetReaderC() assetfsapi.AssetReaderFuncC

func (*AssetGetter) MustAsset

func (f *AssetGetter) MustAsset(path string) assetfsapi.AssetInterface

func (*AssetGetter) MustAssetC

func (f *AssetGetter) MustAssetC(ctx context.Context, path string) assetfsapi.AssetInterface

func (*AssetGetter) MustAssetInfo

func (f *AssetGetter) MustAssetInfo(path string) assetfsapi.FileInfo

func (*AssetGetter) MustAssetInfoC

func (f *AssetGetter) MustAssetInfoC(ctx context.Context, path string) assetfsapi.FileInfo

func (*AssetGetter) Provider

func (f *AssetGetter) Provider(providers ...Interface)

func (*AssetGetter) Providers

func (f *AssetGetter) Providers() []Interface

type AssetInterface

type AssetInterface = assetfsapi.AssetInterface

type Compresseder

type Compresseder = assetfsapi.Compresseder

type DefaultGlobPattern

type DefaultGlobPattern struct {
	GlobBase
	// contains filtered or unexported fields
}

func (*DefaultGlobPattern) Glob

func (gp *DefaultGlobPattern) Glob() glob.Glob

func (*DefaultGlobPattern) Match

func (gp *DefaultGlobPattern) Match(value string) bool

func (DefaultGlobPattern) PathFormatter

func (DefaultGlobPattern) Recursive

func (gp DefaultGlobPattern) Recursive() assetfsapi.GlobPattern

func (DefaultGlobPattern) Wrap

type Glob

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

func NewGlob

func NewGlob(fs assetfsapi.Interface, pattern assetfsapi.GlobPattern) *Glob

func (*Glob) FS

func (g *Glob) FS() assetfsapi.Interface

func (*Glob) GetPattern

func (g *Glob) GetPattern() assetfsapi.GlobPattern

func (*Glob) Info

func (g *Glob) Info(cb func(info assetfsapi.FileInfo) error) error

func (*Glob) InfoOrPanic

func (g *Glob) InfoOrPanic(cb func(info assetfsapi.FileInfo) error)

func (*Glob) Infos

func (g *Glob) Infos() (items []assetfsapi.FileInfo, err error)

func (*Glob) InfosOrPanic

func (g *Glob) InfosOrPanic() []assetfsapi.FileInfo

func (*Glob) Name

func (g *Glob) Name(cb func(pth string, isDir bool) error) error

func (*Glob) NameOrPanic

func (g *Glob) NameOrPanic(cb func(pth string, isDir bool) error)

func (*Glob) Names

func (g *Glob) Names() (items []string, err error)

func (*Glob) NamesOrPanic

func (g *Glob) NamesOrPanic() []string

func (*Glob) SetPattern

func (g *Glob) SetPattern(pattern assetfsapi.GlobPattern)

func (*Glob) SortedInfos

func (g *Glob) SortedInfos() (items []assetfsapi.FileInfo, err error)

func (*Glob) SortedNames

func (g *Glob) SortedNames() (items []string, err error)

type GlobBase

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

func (*GlobBase) AllowDirs

func (gp *GlobBase) AllowDirs() bool

func (*GlobBase) AllowFiles

func (gp *GlobBase) AllowFiles() bool

func (*GlobBase) Dir

func (gp *GlobBase) Dir() string

func (*GlobBase) GetPathFormatter

func (gp *GlobBase) GetPathFormatter() assetfsapi.PathFormatterFunc

func (*GlobBase) IsRecursive

func (gp *GlobBase) IsRecursive() bool

func (*GlobBase) Pattern

func (gp *GlobBase) Pattern() string

type GlobPatter

type GlobPatter = assetfsapi.GlobPattern

type Interface

type Interface = assetfsapi.Interface

func FakeFileSystem

func FakeFileSystem() Interface

type NameSpaceFileInfo

type NameSpaceFileInfo struct {
	assetfsapi.BasicFileInfo
	// contains filtered or unexported fields
}

func (*NameSpaceFileInfo) GetFileInfo

func (ns *NameSpaceFileInfo) GetFileInfo() os.FileInfo

func (*NameSpaceFileInfo) IsDir

func (ns *NameSpaceFileInfo) IsDir() bool

func (*NameSpaceFileInfo) ModTime

func (ns *NameSpaceFileInfo) ModTime() time.Time

func (*NameSpaceFileInfo) Mode

func (ns *NameSpaceFileInfo) Mode() os.FileMode

func (*NameSpaceFileInfo) ReadDir

func (ns *NameSpaceFileInfo) ReadDir(cb func(child assetfsapi.FileInfo) error) (err error)

func (*NameSpaceFileInfo) Reader

func (ns *NameSpaceFileInfo) Reader() (io.ReadCloser, error)

func (*NameSpaceFileInfo) RealPath

func (ns *NameSpaceFileInfo) RealPath() string

func (*NameSpaceFileInfo) Size

func (ns *NameSpaceFileInfo) Size() int64

func (*NameSpaceFileInfo) String

func (ns *NameSpaceFileInfo) String() string

func (*NameSpaceFileInfo) Sys

func (ns *NameSpaceFileInfo) Sys() interface{}

func (NameSpaceFileInfo) Type

func (*NameSpaceFileInfo) Writer

func (ns *NameSpaceFileInfo) Writer() (io.WriteCloser, error)

type NormalPattern

type NormalPattern struct {
	GlobBase
}

func (*NormalPattern) Match

func (gp *NormalPattern) Match(value string) bool

func (NormalPattern) PathFormatter

func (gp NormalPattern) PathFormatter(formatter assetfsapi.PathFormatterFunc) assetfsapi.GlobPattern

func (*NormalPattern) Recursive

func (gp *NormalPattern) Recursive() assetfsapi.GlobPattern

func (NormalPattern) Wrap

func (gp NormalPattern) Wrap(dir ...string) assetfsapi.GlobPattern

type RawFileSystem

type RawFileSystem struct {
	*AssetFileSystem
}

type RealDirFileInfo

type RealDirFileInfo struct {
	*RealFileInfo
}

func (*RealDirFileInfo) Appender

func (rf *RealDirFileInfo) Appender() (io.WriteCloser, error)

func (*RealDirFileInfo) ReadDir

func (d *RealDirFileInfo) ReadDir(cb func(child assetfsapi.FileInfo) error) (err error)

func (*RealDirFileInfo) Reader

func (rf *RealDirFileInfo) Reader() (io.ReadCloser, error)

func (*RealDirFileInfo) String

func (rf *RealDirFileInfo) String() string

func (RealDirFileInfo) Type

func (*RealDirFileInfo) Writer

func (rf *RealDirFileInfo) Writer() (io.WriteCloser, error)

type RealFileInfo

type RealFileInfo struct {
	assetfsapi.BasicFileInfo
	// contains filtered or unexported fields
}

func NewRealFileInfo

func NewRealFileInfo(basicFileInfo assetfsapi.BasicFileInfo, realPath string) *RealFileInfo

func (*RealFileInfo) Appender

func (rf *RealFileInfo) Appender() (io.WriteCloser, error)

func (*RealFileInfo) GetFileInfo

func (rf *RealFileInfo) GetFileInfo() os.FileInfo

func (*RealFileInfo) Reader

func (rf *RealFileInfo) Reader() (io.ReadCloser, error)

func (*RealFileInfo) RealPath

func (rf *RealFileInfo) RealPath() string

func (*RealFileInfo) String

func (rf *RealFileInfo) String() string

func (RealFileInfo) Type

func (*RealFileInfo) Writer

func (rf *RealFileInfo) Writer() (io.WriteCloser, error)

type StaticHandler

type StaticHandler struct {
	EtagTimeLife time.Duration

	FS assetfsapi.Interface
	// contains filtered or unexported fields
}

func NewStaticHandler

func NewStaticHandler(fs assetfsapi.Interface) *StaticHandler

func (*StaticHandler) ServeAsset

func (this *StaticHandler) ServeAsset(w http.ResponseWriter, r *http.Request, pth string, notFound ...bool)

func (*StaticHandler) ServeHTTP

func (this *StaticHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Traversable

type Traversable struct {
	FS           Interface
	WalkFunc     assetfsapi.WalkFunc
	WalkInfoFunc assetfsapi.WalkInfoFunc
	ReadDirFunc  func(dir string, cb assetfsapi.CbWalkInfoFunc, skipDir bool) error
	GlobFunc     assetfsapi.GlobFunc
	GlobInfoFunc assetfsapi.GlobInfoFunc
}

func (*Traversable) Glob

func (f *Traversable) Glob(pattern assetfsapi.GlobPattern, cb func(pth string, isDir bool) error) error

func (*Traversable) GlobInfo

func (f *Traversable) GlobInfo(pattern assetfsapi.GlobPattern, cb func(info assetfsapi.FileInfo) error) error

func (*Traversable) NewGlob

func (f *Traversable) NewGlob(pattern assetfsapi.GlobPattern) assetfsapi.Glob

func (*Traversable) NewGlobString

func (f *Traversable) NewGlobString(pattern string) assetfsapi.Glob

func (*Traversable) ReadDir

func (t *Traversable) ReadDir(dir string, cb assetfsapi.CbWalkInfoFunc, skipDir bool) (err error)

func (*Traversable) Walk

func (t *Traversable) Walk(dir string, cb assetfsapi.CbWalkFunc, mode ...assetfsapi.WalkMode) error

func (*Traversable) WalkInfo

func (t *Traversable) WalkInfo(dir string, cb assetfsapi.CbWalkInfoFunc, mode ...assetfsapi.WalkMode) error

Directories

Path Synopsis
t

Jump to

Keyboard shortcuts

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