Documentation ¶
Index ¶
- Constants
- Variables
- func Cascade(shortCircuit bool, providers ...ConfigProvider) *configSource
- func DeepCopy(conf interface{}) (interface{}, error)
- func Default(defaultConfig interface{}) *configSource
- func EachOf(providers ...ConfigProvider) *configSource
- func Environment(key string) *configSource
- func File(configFile string, skipNonExistent bool) *configSource
- func FirstOf(providers ...ConfigProvider) *configSource
- func FromFile(configFile string, conf interface{}) error
- func FromJSONString(jsonString string, conf interface{}) error
- func FromString(configString string, conf interface{}) error
- func FromTOMLString(tomlString string, conf interface{}) error
- func JSONString(conf interface{}) string
- func Merge(base, override interface{}) (interface{}, error)
- func NewConfigProvider(from string, skip bool, apply func(baseConfig interface{}) error) *configSource
- func ReadFile(file string) ([]byte, error)
- func ShouldSkipFile(file string, skipNonExistent bool) bool
- func TOMLString(conf interface{}) string
- func XDGBaseDir(configFileName string) *configSource
- type ConfigProvider
- type Format
Constants ¶
const STDINFileIdentifier = "-"
If passed this identifier try to read config from STDIN
Variables ¶
var LogWriter io.Writer
Functions ¶
func Cascade ¶
func Cascade(shortCircuit bool, providers ...ConfigProvider) *configSource
Builds a ConfigProvider by iterating over a cascade of ConfigProvider sources. Can be used in two distinct modes: with shortCircuit true the first successful ConfigProvider source is returned. With shortCircuit false sources appearing later are used to possibly override those appearing earlier
func DeepCopy ¶
func DeepCopy(conf interface{}) (interface{}, error)
Passed a pointer to struct creates a deep copy of the struct
func EachOf ¶
func EachOf(providers ...ConfigProvider) *configSource
func Environment ¶
func Environment(key string) *configSource
Source from a single environment variable with config embedded in JSON
func File ¶
Try to source config from provided file detecting the file format, is skipNonExistent is true then the provider will fall-through (skip) when the file doesn't exist, rather than returning an error
func FirstOf ¶
func FirstOf(providers ...ConfigProvider) *configSource
func FromJSONString ¶
func FromString ¶
func FromTOMLString ¶
func JSONString ¶
func JSONString(conf interface{}) string
func NewConfigProvider ¶
func ShouldSkipFile ¶
func TOMLString ¶
func TOMLString(conf interface{}) string
func XDGBaseDir ¶
func XDGBaseDir(configFileName string) *configSource
Try to find config by using XDG base dir spec
Types ¶
type ConfigProvider ¶
type ConfigProvider interface { // Description of where this provider sources its config from From() string // Get the config values to the passed in baseConfig Apply(baseConfig interface{}) error // Return a copy of the provider that does nothing if skip is true SetSkip(skip bool) ConfigProvider // Whether to skip this provider Skip() bool }