Documentation ¶
Index ¶
- Variables
- func DefaultIntValue(i int64) interface{ ... }
- func DefaultStringValue(s string) interface{ ... }
- type ArrayValueBinder
- type BindFieldMissingError
- type BindValueError
- type Binding
- type BindingFromSource
- type BoolValueBinder
- type CustomValueBinder
- type DefaultCustomValue
- type Field
- func NewBoolField(dest *bool, sources ...BoolValueBinder) Field
- func NewCustomField(dest interface{}, sources ...CustomValueBinder) Field
- func NewInt16Field(dest *int16, sources ...IntValueBinder) Field
- func NewInt16SliceField(dest *[]int16, sources ...ArrayValueBinder) Field
- func NewInt32Field(dest *int32, sources ...IntValueBinder) Field
- func NewInt32SliceField(dest *[]int32, sources ...ArrayValueBinder) Field
- func NewInt64Field(dest *int64, sources ...IntValueBinder) Field
- func NewInt64SliceField(dest *[]int64, sources ...ArrayValueBinder) Field
- func NewInt8Field(dest *int8, sources ...IntValueBinder) Field
- func NewInt8SliceField(dest *[]int8, sources ...ArrayValueBinder) Field
- func NewIntField(dest *int, sources ...IntValueBinder) Field
- func NewIntSliceField(dest *[]int, sources ...ArrayValueBinder) Field
- func NewStringField(dest *string, sources ...StringValueBinder) Field
- func NewTextBasedField(dest encoding.TextUnmarshaler, sources ...TextBasedValueBinder) Field
- func NewUint16Field(dest *uint16, sources ...UintValueBinder) Field
- func NewUint16SliceField(dest *[]uint16, sources ...ArrayValueBinder) Field
- func NewUint32Field(dest *uint32, sources ...UintValueBinder) Field
- func NewUint32SliceField(dest *[]uint32, sources ...ArrayValueBinder) Field
- func NewUint64Field(dest *uint64, sources ...UintValueBinder) Field
- func NewUint64SliceField(dest *[]uint64, sources ...ArrayValueBinder) Field
- func NewUint8Field(dest *uint8, sources ...UintValueBinder) Field
- func NewUint8SliceField(dest *[]uint8, sources ...ArrayValueBinder) Field
- func NewUintField(dest *uint, sources ...UintValueBinder) Field
- func NewUintSliceField(dest *[]uint, sources ...ArrayValueBinder) Field
- type FloatValueBinder
- type IntValueBinder
- type JSONSourceInitError
- type LazySingleValueBinder
- type ManagedField
- type ManagedFieldOption
- type Manager
- type ManagerOption
- type Source
- type SourceCLI
- type SourceEnvVars
- type SourceGoMap
- type SourceJSON
- type StringValueBinder
- type TextBasedValueBinder
- type UintValueBinder
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorMissing = errors.New("field is missing in config source") // TODO: remove?
Functions ¶
func DefaultIntValue ¶
func DefaultIntValue(i int64) interface { IntValueBinder }
func DefaultStringValue ¶
func DefaultStringValue(s string) interface { StringValueBinder TextBasedValueBinder }
Types ¶
type ArrayValueBinder ¶
type ArrayValueBinder interface {
BindArrayValueTo(length *int, element *func(int) LazySingleValueBinder) Binding
}
TODO: rename to List or Slice instead of Array?
type BindFieldMissingError ¶
func NewBindFieldMissingError ¶
func NewBindFieldMissingError(srcName string, field string) *BindFieldMissingError
func (*BindFieldMissingError) Error ¶
func (e *BindFieldMissingError) Error() string
type BindValueError ¶
type BindValueError struct { Func string // the failing function (like BindIntValueTo) Input string // the input Err error // the reason the conversion failed }
func NewBindValueError ¶
func NewBindValueError(f string, input string, err error) *BindValueError
func (*BindValueError) Error ¶
func (e *BindValueError) Error() string
Error implements error interface
func (*BindValueError) Unwrap ¶
func (e *BindValueError) Unwrap() error
type BindingFromSource ¶
func NewCallbackBindingFromSource ¶
func NewCallbackBindingFromSource(source Source, boundName string, callback func() error) BindingFromSource
type BoolValueBinder ¶
type CustomValueBinder ¶
type CustomValueBinder interface {
BindValue() Binding
}
type DefaultCustomValue ¶
type DefaultCustomValue func()
func (DefaultCustomValue) BindValue ¶
func (dcv DefaultCustomValue) BindValue() Binding
func (DefaultCustomValue) Source ¶
func (dcv DefaultCustomValue) Source() Source
type Field ¶
type Field interface { Destination() interface{} Bindings() []Binding }
func NewBoolField ¶
func NewBoolField(dest *bool, sources ...BoolValueBinder) Field
func NewCustomField ¶
func NewCustomField(dest interface{}, sources ...CustomValueBinder) Field
func NewInt16Field ¶
func NewInt16Field(dest *int16, sources ...IntValueBinder) Field
func NewInt16SliceField ¶
func NewInt16SliceField(dest *[]int16, sources ...ArrayValueBinder) Field
func NewInt32Field ¶
func NewInt32Field(dest *int32, sources ...IntValueBinder) Field
func NewInt32SliceField ¶
func NewInt32SliceField(dest *[]int32, sources ...ArrayValueBinder) Field
func NewInt64Field ¶
func NewInt64Field(dest *int64, sources ...IntValueBinder) Field
func NewInt64SliceField ¶
func NewInt64SliceField(dest *[]int64, sources ...ArrayValueBinder) Field
func NewInt8Field ¶
func NewInt8Field(dest *int8, sources ...IntValueBinder) Field
func NewInt8SliceField ¶
func NewInt8SliceField(dest *[]int8, sources ...ArrayValueBinder) Field
func NewIntField ¶
func NewIntField(dest *int, sources ...IntValueBinder) Field
func NewIntSliceField ¶
func NewIntSliceField(dest *[]int, sources ...ArrayValueBinder) Field
func NewStringField ¶
func NewStringField(dest *string, sources ...StringValueBinder) Field
func NewTextBasedField ¶
func NewTextBasedField(dest encoding.TextUnmarshaler, sources ...TextBasedValueBinder) Field
func NewUint16Field ¶
func NewUint16Field(dest *uint16, sources ...UintValueBinder) Field
func NewUint16SliceField ¶
func NewUint16SliceField(dest *[]uint16, sources ...ArrayValueBinder) Field
func NewUint32Field ¶
func NewUint32Field(dest *uint32, sources ...UintValueBinder) Field
func NewUint32SliceField ¶
func NewUint32SliceField(dest *[]uint32, sources ...ArrayValueBinder) Field
func NewUint64Field ¶
func NewUint64Field(dest *uint64, sources ...UintValueBinder) Field
func NewUint64SliceField ¶
func NewUint64SliceField(dest *[]uint64, sources ...ArrayValueBinder) Field
func NewUint8Field ¶
func NewUint8Field(dest *uint8, sources ...UintValueBinder) Field
func NewUint8SliceField ¶
func NewUint8SliceField(dest *[]uint8, sources ...ArrayValueBinder) Field
func NewUintField ¶
func NewUintField(dest *uint, sources ...UintValueBinder) Field
func NewUintSliceField ¶
func NewUintSliceField(dest *[]uint, sources ...ArrayValueBinder) Field
type FloatValueBinder ¶
type IntValueBinder ¶
type JSONSourceInitError ¶
func NewJSONSourceInitError ¶
func NewJSONSourceInitError(data []byte, err error) *JSONSourceInitError
func (*JSONSourceInitError) Error ¶
func (e *JSONSourceInitError) Error() string
Error implements error interface
func (*JSONSourceInitError) Unwrap ¶
func (e *JSONSourceInitError) Unwrap() error
type LazySingleValueBinder ¶
type LazySingleValueBinder interface { StringValueBinder IntValueBinder UintValueBinder FloatValueBinder BoolValueBinder TextBasedValueBinder }
type ManagedField ¶
type ManagedField struct { Field Name string DefaultValue string Description string Required bool Validator func() error // contains filtered or unexported fields }
func (*ManagedField) Consolidate ¶
func (mf *ManagedField) Consolidate() []error
func (*ManagedField) HasBeenSetFromSource ¶
func (mf *ManagedField) HasBeenSetFromSource() bool
func (*ManagedField) LastBindingFromSource ¶
func (mf *ManagedField) LastBindingFromSource() BindingFromSource
func (*ManagedField) Validate ¶
func (mf *ManagedField) Validate() error
type ManagedFieldOption ¶
type ManagedFieldOption func(*ManagedField)
func IsRequired ¶
func IsRequired() ManagedFieldOption
func WithDescription ¶
func WithDescription(description string) ManagedFieldOption
func WithName ¶
func WithName(name string) ManagedFieldOption
func WithValidator ¶
func WithValidator(validator func() error) ManagedFieldOption
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(options ...ManagerOption) *Manager
func (*Manager) AddField ¶
func (m *Manager) AddField(field Field, options ...ManagedFieldOption) *ManagedField
func (*Manager) Consolidate ¶
func (*Manager) Field ¶
func (m *Manager) Field(dest interface{}) *ManagedField
func (*Manager) Fields ¶
func (m *Manager) Fields() []*ManagedField
type ManagerOption ¶
type ManagerOption func(*Manager)
func WithDefaultSourceOfFieldNames ¶
func WithDefaultSourceOfFieldNames(source Source) ManagerOption
WithDefaultSourceOfFieldNames designates a specific Source as the canonical source of field names. For example, that way all validation errors and help texts will always use the JSON property names or the CLI flag names.
type SourceCLI ¶
type SourceCLI struct {
// contains filtered or unexported fields
}
func NewSourceFromCLIFlags ¶
func (*SourceCLI) FromNameAndShorthand ¶
func (*SourceCLI) FromPositionalArg ¶
func (*SourceCLI) Initialize ¶
type SourceEnvVars ¶
type SourceEnvVars struct {
// contains filtered or unexported fields
}
func NewSourceFromEnv ¶
func NewSourceFromEnv(environ []string) *SourceEnvVars
func (*SourceEnvVars) From ¶
func (sev *SourceEnvVars) From(name string) *envBinder
func (*SourceEnvVars) GetName ¶
func (sev *SourceEnvVars) GetName() string
func (*SourceEnvVars) Initialize ¶
func (sev *SourceEnvVars) Initialize() error
type SourceGoMap ¶
type SourceGoMap struct {
// contains filtered or unexported fields
}
func NewGoMapSource ¶
func NewGoMapSource(values map[string]interface{}) (*SourceGoMap, error)
type SourceJSON ¶
type SourceJSON struct {
// contains filtered or unexported fields
}
TODO: rename this to something else? e.g. JSONDocument?
func NewJSONSource ¶
func NewJSONSource(data []byte) *SourceJSON
func (*SourceJSON) From ¶
func (sj *SourceJSON) From(name string) *jsonBinder
func (*SourceJSON) GetName ¶
func (sj *SourceJSON) GetName() string
func (*SourceJSON) Initialize ¶
func (sj *SourceJSON) Initialize() error
func (*SourceJSON) Lookup ¶
func (sj *SourceJSON) Lookup(name string) (json.RawMessage, bool)
type StringValueBinder ¶
type TextBasedValueBinder ¶
type TextBasedValueBinder interface {
BindTextBasedValueTo(dest encoding.TextUnmarshaler) Binding
}
type UintValueBinder ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.