Documentation
¶
Overview ¶
Package config supports go text/template, environment and self defined variables
Index ¶
- func LoadYAMLAsStruct(file string, structuredConfig interface{}) error
- func LoadYAMLDirect(file string, cfg interface{}) error
- func LoadYAMLDirectFrom(r io.Reader, cfg interface{}) error
- func LoadYAMLDirectFromStrict(r io.Reader, cfg interface{}) error
- func LoadYAMLDirectStrict(file string, cfg interface{}) error
- func SplitMultiDocument(data []byte) [][]byte
- type Path
- type Reader
- type StructuredConfig
- type YAMLConfig
- func (c *YAMLConfig) Env(name string) string
- func (c *YAMLConfig) EnvOr(name string, defaultVal string) string
- func (c *YAMLConfig) FuncMaps() template.FuncMap
- func (c *YAMLConfig) Get(key string) interface{}
- func (c *YAMLConfig) GetLogger() *dlog.Logger
- func (c *YAMLConfig) GetOrDefault(key string, defaultVal interface{}) interface{}
- func (c *YAMLConfig) GetOrFail(key string) (interface{}, error)
- func (c *YAMLConfig) LoggerIdentity(justCallMe func() *dlog.Identity) *dlog.Identity
- func (c *YAMLConfig) ParseMultiDocument(data []byte) error
- func (c *YAMLConfig) ParseSingleDocument(doc []byte) error
- func (c *YAMLConfig) SetLogger(logger *dlog.Logger)
- func (c *YAMLConfig) Unmarshal(structuredConfig interface{}, removeVars bool) error
- func (c *YAMLConfig) UnmarshalKey(key string, structuredConfig interface{}) error
- func (c *YAMLConfig) Var(name string) interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadYAMLAsStruct ¶
LoadYAMLAsStruct is a convenient wrapper for loading a single YAML file into struct, you should pass a pointer to the struct as second argument. It will remove the vars section.
func LoadYAMLDirect ¶ added in v0.0.6
func LoadYAMLDirectFrom ¶ added in v0.0.6
func LoadYAMLDirectFromStrict ¶ added in v0.0.6
func LoadYAMLDirectStrict ¶ added in v0.0.6
func SplitMultiDocument ¶
SplitMultiDocument splits a yaml file that contains multiple documents and (only) trim the first one if it is empty
Types ¶
type StructuredConfig ¶
type StructuredConfig interface {
Validate() error
}
type YAMLConfig ¶
type YAMLConfig struct {
// contains filtered or unexported fields
}
YAMLConfig is a thread safe struct for parse YAML file and get value
func NewYAMLConfig ¶
func NewYAMLConfig() *YAMLConfig
NewYAMLConfig returns a config with internal map structure initialized
func (*YAMLConfig) Env ¶
func (c *YAMLConfig) Env(name string) string
func (*YAMLConfig) FuncMaps ¶
func (c *YAMLConfig) FuncMaps() template.FuncMap
func (*YAMLConfig) Get ¶
func (c *YAMLConfig) Get(key string) interface{}
func (*YAMLConfig) GetLogger ¶
func (c *YAMLConfig) GetLogger() *dlog.Logger
func (*YAMLConfig) GetOrDefault ¶
func (c *YAMLConfig) GetOrDefault(key string, defaultVal interface{}) interface{}
func (*YAMLConfig) GetOrFail ¶
func (c *YAMLConfig) GetOrFail(key string) (interface{}, error)
func (*YAMLConfig) LoggerIdentity ¶
func (c *YAMLConfig) LoggerIdentity(justCallMe func() *dlog.Identity) *dlog.Identity
func (*YAMLConfig) ParseMultiDocument ¶
func (c *YAMLConfig) ParseMultiDocument(data []byte) error
func (*YAMLConfig) ParseSingleDocument ¶
func (c *YAMLConfig) ParseSingleDocument(doc []byte) error
func (*YAMLConfig) SetLogger ¶
func (c *YAMLConfig) SetLogger(logger *dlog.Logger)
func (*YAMLConfig) Unmarshal ¶
func (c *YAMLConfig) Unmarshal(structuredConfig interface{}, removeVars bool) error
func (*YAMLConfig) UnmarshalKey ¶
func (c *YAMLConfig) UnmarshalKey(key string, structuredConfig interface{}) error
func (*YAMLConfig) Var ¶
func (c *YAMLConfig) Var(name string) interface{}
Click to show internal directories.
Click to hide internal directories.