Documentation
¶
Overview ¶
MIT Licensed
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidSpecification = errors.New("specification must be a struct pointer")
ErrInvalidSpecification indicates that a specification is of the wrong type.
Functions ¶
func MustProcess ¶
func MustProcess(v TagValueGetter, spec interface{})
MustProcess is the same as Process but panics if an error occurs
func PopulateExternalSource ¶
func PopulateExternalSource(v TagValueSetter, spec interface{}) error
PopulateExternalSource is used to fill an external source when a struct contains values. An external source can include an in memory store, environment variables, a properties store, and so forth. Therefore, if a struct contains values, but you want to propagate said values to another location, this would allow you to do so based off of how the TagValueSetter has been implemented.
func Process ¶
func Process(v TagValueGetter, spec interface{}) error
Process populates the specified struct based on the TagValueGetter implementation
Types ¶
type Decoder ¶
A Decoder is a type that knows how to de-serialize environment variables into itself.
type ParseError ¶
A ParseError occurs when an environment variable cannot be converted to the type required by a struct field during assignment.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type TagNameGetter ¶
type TagNameGetter interface {
TagName() string
}
TagNameGetter is used for defining a struct tag that contains the value in question.
type TagValueGetter ¶
type TagValueGetter interface {
TagNameGetter
Get(key string, t reflect.StructField) string
}
TagValueGetter is an interface to allow for different k,v stores to be passed to the Process func. TagName is the name of the tag Process looks for, to query the TagValueGetter Get is passed a key to look up and the StructField so it can inspect for other tags it might care about.
type TagValueSetter ¶
type TagValueSetter interface {
TagNameGetter
Set(key string, value interface{}, t reflect.StructField) error
}
TagValueSetter is used to set a value onto an external source based on the tag name.