loader

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader interface {
	// Root returns the scheme-specific string representing 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)
}

Loader interface exposes methods to read bytes in a scheme-agnostic manner. The Loader encapsulating a root location to calculate where to read from.

func Init

func Init(schemes []SchemeLoader) Loader

Init initializes the first loader with the supported schemes. Example schemes: fileLoader, httpLoader, gitLoader.

type SchemeLoader

type SchemeLoader interface {
	// Does this location correspond to this scheme.
	IsScheme(root string, location string) bool
	// Combines the root and path into a full location string.
	FullLocation(root string, path string) (string, error)
	// Load bytes at scheme-specific location or an error.
	Load(location string) ([]byte, error)
}

Interface for different types of loaders (e.g. fileLoader, httpLoader, etc.)

func NewFileLoader

func NewFileLoader(fs fs.FileSystem) SchemeLoader

NewFileLoader returns a SchemeLoader to handle a file system.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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