loader

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

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.

func (*FileLoader) IsAbsPath added in v1.0.5

func (l *FileLoader) IsAbsPath(root string, location string) bool

IsAbsPath return true if the location calculated with the root and location params a full file path.

func (*FileLoader) Load added in v1.0.5

func (l *FileLoader) Load(p string) ([]byte, error)

Load returns the bytes from reading a file at fullFilePath. 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.

Jump to

Keyboard shortcuts

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