Documentation ¶
Overview ¶
Package confusion provides a simple mechanism for loading configuration files of arbitrary formats from a number of alternate locations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrConfigNotFound is returned when LoadConfig is unable to locate // a suitable configuration file in any of the provided locations. ErrConfigNotFound = errors.New("config not found") // ErrLoaderNotFound is returned by LoadConfig if a configuration // file is found but it cannot be loaded because no Loader matching // its file extension is available. ErrLoaderNotFound = errors.New("loader not found") )
Functions ¶
Types ¶
type Loader ¶
type Loader interface { // Load attemtps to load a configuration file from r and store the // result in v. Load(r io.Reader, v interface{}) error }
A Loader is responsible for loading configuration files of a specific format.
type Options ¶
type Options struct { Prefix string Paths []string Loaders map[string]Loader // contains filtered or unexported fields }
Options determines where LoadConfig will look for configuration files and what formats can be loaded.
Loaders maps file extensions (e.g., ".json") to a Loader that is capable of loading configuration files with this extension.
Click to show internal directories.
Click to hide internal directories.