Documentation
¶
Index ¶
- func ExtractUnmarshalFunc(c Configurer, key string) func(interface{}) error
- func IsErrKeyMissing(e error) bool
- type Configurer
- type ConfigurerWithAliases
- func (c *ConfigurerWithAliases) Alias(virtual, real string)
- func (c ConfigurerWithAliases) Has(key string) bool
- func (c ConfigurerWithAliases) KeyFunc(key string) func(interface{}) error
- func (c ConfigurerWithAliases) UnmarshalKey(key string, target interface{}) error
- func (c ConfigurerWithAliases) Validate() error
- type ErrKeyMissing
- type List
- type Map
- type Validable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractUnmarshalFunc ¶
func ExtractUnmarshalFunc(c Configurer, key string) func(interface{}) error
ExtractUnmarshalFunc is helper function used to create Unmarshaling function for provided key
func IsErrKeyMissing ¶
IsErrKeyMissing returns true if provided error is instance of ErrKeyMissing
Types ¶
type Configurer ¶
type Configurer interface {
// Has returns true if configurer has requested field
Has(string) bool
// UnmarshalKey writes configuration value from string key into interface target
UnmarshalKey(string, interface{}) error
// KeyFunc return Unmarshaling function for requested key
KeyFunc(string) func(interface{}) error
}
Configurer interface describes configuration source
func ErrConfigurer ¶
func ErrConfigurer(err error) Configurer
ErrConfigurer builds configuration source, that will return an error on any action and false on Has invocation
func NewValidableConfig ¶
func NewValidableConfig(source Configurer) Configurer
NewValidableConfig returns adapter for provided configurer, that runs Validate function on all returning configuration values if this value has Validate method
type ConfigurerWithAliases ¶
type ConfigurerWithAliases struct {
// contains filtered or unexported fields
}
ConfigurerWithAliases is special configurer adapter, that works with aliases
func NewConfigurationWithAliases ¶
func NewConfigurationWithAliases(real Configurer) *ConfigurerWithAliases
NewConfigurationWithAliases creates new configurere with empty aliases list
func (*ConfigurerWithAliases) Alias ¶
func (c *ConfigurerWithAliases) Alias(virtual, real string)
Alias registers new alias
func (ConfigurerWithAliases) Has ¶
func (c ConfigurerWithAliases) Has(key string) bool
Has returns true if configurer has requested field
func (ConfigurerWithAliases) KeyFunc ¶
func (c ConfigurerWithAliases) KeyFunc(key string) func(interface{}) error
KeyFunc return Unmarshaling function for requested key
func (ConfigurerWithAliases) UnmarshalKey ¶
func (c ConfigurerWithAliases) UnmarshalKey(key string, target interface{}) error
UnmarshalKey writes configuration value from string key into interface target
func (ConfigurerWithAliases) Validate ¶
func (c ConfigurerWithAliases) Validate() error
Validate performs validation of all configs inside list
type ErrKeyMissing ¶
type ErrKeyMissing struct {
Key string
}
ErrKeyMissing is special error, thrown when missing key is requested
func (ErrKeyMissing) Error ¶
func (e ErrKeyMissing) Error() string
type List ¶
type List []Configurer
List represents slice of configurers and is configurer by itself Configurers in list are processed backwards, so last one has maximum priority
func (List) UnmarshalKey ¶
UnmarshalKey writes configuration value from string key into interface target
type Map ¶
type Map map[string]interface{}
Map is configuration provider, based on simple hash map
func (Map) UnmarshalKey ¶
UnmarshalKey writes configuration value from string key into interface target