View Source
const STDINFileIdentifier = "-"

    If passed this identifier try to read config from STDIN


    View Source
    var LogWriter io.Writer


    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 Default

        func Default(defaultConfig interface{}) *configSource

        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

          func File(configFile string, skipNonExistent bool) *configSource

            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 FromFile

            func FromFile(configFile string, conf interface{}) error

            func FromJSONString

            func FromJSONString(jsonString string, conf interface{}) error

            func FromString

            func FromString(configString string, conf interface{}) error

            func FromTOMLString

            func FromTOMLString(tomlString string, conf interface{}) error

            func JSONString

            func JSONString(conf interface{}) string

            func Merge

            func Merge(base, override interface{}) (interface{}, error)

            func NewConfigProvider

            func NewConfigProvider(from string, skip bool, apply func(baseConfig interface{}) error) *configSource

            func ReadFile

            func ReadFile(file string) ([]byte, error)

            func ShouldSkipFile

            func ShouldSkipFile(file string, skipNonExistent bool) bool

            func TOMLString

            func TOMLString(conf interface{}) string

            func XDGBaseDir

            func XDGBaseDir(configFileName string) *configSource

              Try to find config by using XDG base dir spec


              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

              type Format

              type Format string
              const (
              	JSON    Format = "JSON"
              	TOML    Format = "TOML"
              	Unknown Format = ""

              func DetectFormat

              func DetectFormat(configString string) Format

              Source Files