Documentation ¶
Overview ¶
Package hooks helps to configure hook configurations from a map. It's a wrapper around mapstructure.
The main functions to be used are:
RegisterInterface: just use once to register an interface type Register: used to register possible kinds of an interface Decode: used once to decode the config
All other functions are for advanced uses.
Index ¶
- func Decode(in, out interface{}) error
- func DecodeElementsHookFunc() mapstructure.DecodeHookFunc
- func DefaultDecoderConfig(output interface{}) *mapstructure.DecoderConfig
- func InitRegistry()
- func Register(forType reflect.Type, kind string, f func() interface{})
- func RegisterInterface(forType reflect.Type, key string)
- func StringToStringUnmarshallerHookFunc() mapstructure.DecodeHookFunc
- type NewHookFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
func Decode(in, out interface{}) error
Decode transkripts map[interface{}]interface{} to the target struct
func DecodeElementsHookFunc ¶
func DecodeElementsHookFunc() mapstructure.DecodeHookFunc
DecodeElementsHookFunc returns a DecodeHookFunc that converts maps to a Hook config derived from a registry.
func DefaultDecoderConfig ¶
func DefaultDecoderConfig(output interface{}) *mapstructure.DecoderConfig
DefaultDecoderConfig returns default mapstructure.DecoderConfig with support of time.Duration values and Plugins
func InitRegistry ¶
func InitRegistry()
InitRegistry resets the registry. It is intended mainly for testing.
func Register ¶
Register registers the factory function for all instances of a given type hint: provide a type for consumers with MyHookType := reflect.TypeOf((*MyHook)(nil)).Elem()
func RegisterInterface ¶
RegisterInterface registers a new interface type; must only be called once!
func StringToStringUnmarshallerHookFunc ¶
func StringToStringUnmarshallerHookFunc() mapstructure.DecodeHookFunc
StringToStringUnmarshallerHookFunc returns a DecodeHookFunc that converts strings by an unmarshaller. Can be used to construct custom DecodeHookFunctions.
Types ¶
type NewHookFunc ¶
type NewHookFunc func() interface{}
NewHookFunc creates a new instance for an registered interface.