Documentation ¶
Overview ¶
Package loader has a data loading interface and various implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileLoader ¶ added in v1.0.5
type FileLoader struct {
// contains filtered or unexported fields
}
FileLoader loads files from a file system.
func NewFileLoader ¶
func NewFileLoader(fs fs.FileSystem) *FileLoader
NewFileLoader returns a new FileLoader.
func (*FileLoader) FullLocation ¶ added in v1.0.5
func (l *FileLoader) FullLocation(root string, location string) (string, error)
FullLocation returns some notion of a full path. If location is a full file path, then ignore root. If location is relative, then join the root path with the location path. Either root or location can be empty, but not both. Special case for ".": Expands to current working directory. Example: "/home/seans/project", "subdir/bar" -> "/home/seans/project/subdir/bar".
func (*FileLoader) GlobLoad ¶ added in v1.0.5
func (l *FileLoader) GlobLoad(p string) (map[string][]byte, error)
GlobLoad returns the map from path to bytes from reading a glob path. Implements the Loader interface.
type Loader ¶
type Loader interface { // Root returns the root location for this Loader. Root() string // New returns Loader located at newRoot. New(newRoot string) (Loader, error) // Load returns the bytes read from the location or an error. Load(location string) ([]byte, error) // GlobLoad returns the bytes read from a glob path or an error. GlobLoad(location string) (map[string][]byte, error) }
Loader interface exposes methods to read bytes.
func NewLoader ¶ added in v1.0.5
func NewLoader(fl *FileLoader) Loader
NewLoader initializes the first loader with the supported fLoader.