Documentation
¶
Index ¶
- Constants
- func FieldTypes() []string
- type AppConfig
- func (c *AppConfig) AddField(fieldSetKey string, field *Field) []error
- func (c *AppConfig) AddFieldSet(fieldSet *FieldSet) []error
- func (c *AppConfig) AddFieldSets(fieldSets ...*FieldSet) []error
- func (c *AppConfig) AppDescription() string
- func (c *AppConfig) AppName() string
- func (c *AppConfig) ConfigMap() map[string]map[string]any
- func (c *AppConfig) GetBool(fieldSetKey, fieldKey string) (bool, error)
- func (c *AppConfig) GetBools(fieldSetKey, fieldKey string) ([]bool, error)
- func (c *AppConfig) GetDuration(fieldSetKey, fieldKey string) (time.Duration, error)
- func (c *AppConfig) GetDurations(fieldSetKey, fieldKey string) ([]time.Duration, error)
- func (c *AppConfig) GetField(fieldSetKey, fieldKey string) (*Field, error)
- func (c *AppConfig) GetFieldSetFieldKeys(fieldSetKey string) ([]string, error)
- func (c *AppConfig) GetFieldSetKeys() []string
- func (c *AppConfig) GetInt(fieldSetKey, fieldKey string) (int, error)
- func (c *AppConfig) GetInts(fieldSetKey, fieldKey string) ([]int, error)
- func (c *AppConfig) GetString(fieldSetKey, fieldKey string) (string, error)
- func (c *AppConfig) GetStrings(fieldSetKey, fieldKey string) ([]string, error)
- func (c *AppConfig) GetTime(fieldSetKey, fieldKey string) (time.Time, error)
- func (c *AppConfig) GetTimes(fieldSetKey, fieldKey string) ([]time.Time, error)
- func (c *AppConfig) HelpString() string
- func (c *AppConfig) LoadField(fieldSetKey, fieldKey string) []error
- func (c *AppConfig) LoadFieldSet(fieldSetKey string) []error
- func (c *AppConfig) Register(handleHelpFlag bool) []error
- func (c *AppConfig) SetField(fieldSetKey, fieldKey string, fieldValue any) error
- func (c *AppConfig) SetLoaders(loaders ...Loader) []error
- type EnvironmentLoader
- func (l *EnvironmentLoader) Clone() *EnvironmentLoader
- func (l *EnvironmentLoader) CloneLoader() Loader
- func (l *EnvironmentLoader) Get(fieldSetKey, fieldKey string) (string, bool)
- func (l *EnvironmentLoader) GetMap(fieldSetKey string, fieldKeys []string) map[string]string
- func (l *EnvironmentLoader) HelpString(fieldSetKey, fieldKey string) string
- func (l *EnvironmentLoader) Name() string
- type Field
- type FieldBuilder
- func (b *FieldBuilder) Create() *Field
- func (b *FieldBuilder) Default(value any) *FieldBuilder
- func (b *FieldBuilder) DefaultGenerator(value func() (any, error)) *FieldBuilder
- func (b *FieldBuilder) Description(value string) *FieldBuilder
- func (b *FieldBuilder) Enumeration(value ...any) *FieldBuilder
- func (b *FieldBuilder) Key(value string) *FieldBuilder
- func (b *FieldBuilder) LoadConditions(value ...LoadCondition) *FieldBuilder
- func (b *FieldBuilder) Required() *FieldBuilder
- func (b *FieldBuilder) Sensitive() *FieldBuilder
- func (b *FieldBuilder) Type(value string) *FieldBuilder
- func (b *FieldBuilder) Validator(value func(fieldValue any) error) *FieldBuilder
- type FieldCondition
- type FieldConditionBuilder
- func (b *FieldConditionBuilder) Condition(value func(fieldValue any) (bool, error)) *FieldConditionBuilder
- func (b *FieldConditionBuilder) Create() LoadCondition
- func (b *FieldConditionBuilder) FieldKey(value string) *FieldConditionBuilder
- func (b *FieldConditionBuilder) FieldSetKey(value string) *FieldConditionBuilder
- type FieldSet
- type FieldSetBuilder
- type FieldSets
- type Fields
- type FlagLoader
- func (l *FlagLoader) Clone() *FlagLoader
- func (l *FlagLoader) CloneLoader() Loader
- func (l *FlagLoader) Get(fieldSetKey, fieldKey string) (string, bool)
- func (l *FlagLoader) GetMap(fieldSetKey string, fieldKeys []string) map[string]string
- func (l *FlagLoader) HelpString(fieldSetKey, fieldKey string) string
- func (l *FlagLoader) Name() string
- type JSONFileLoader
- func (l *JSONFileLoader) Clone() *JSONFileLoader
- func (l *JSONFileLoader) CloneLoader() Loader
- func (l *JSONFileLoader) Get(fieldSetKey, fieldKey string) (string, bool)
- func (l *JSONFileLoader) GetMap(fieldSetKey string, fieldKeys []string) map[string]string
- func (l *JSONFileLoader) HelpString(fieldSetKey, fieldKey string) string
- func (l *JSONFileLoader) Name() string
- type JSONUnmarshal
- type LoadCondition
- type LoadConditions
- type Loader
- type LoaderKeyOverride
Constants ¶
View Source
const ( Bool = "bool" Bools = "[]bool" String = "string" Strings = "[]string" Int = "int" Ints = "[]int" Float = "float64" Floats = "[]float64" Time = "time.Time" Times = "[]time.Time" Duration = "time.Duration" Durations = "[]time.Duration" )
Variables ¶
This section is empty.
Functions ¶
func FieldTypes ¶ added in v0.3.0
func FieldTypes() []string
Types ¶
type AppConfig ¶
type AppConfig struct {
// contains filtered or unexported fields
}
func NewAppConfig ¶
func (*AppConfig) AddFieldSet ¶
func (*AppConfig) AddFieldSets ¶ added in v0.2.0
func (*AppConfig) AppDescription ¶
func (*AppConfig) GetDuration ¶
func (*AppConfig) GetDurations ¶
func (*AppConfig) GetFieldSetFieldKeys ¶
func (*AppConfig) GetFieldSetKeys ¶
func (*AppConfig) GetStrings ¶
func (*AppConfig) HelpString ¶
func (*AppConfig) LoadFieldSet ¶
func (*AppConfig) Register ¶
Register loads all defined field sets and optionally checks for and handles the help flag -h and --help.
func (*AppConfig) SetLoaders ¶
type EnvironmentLoader ¶
type EnvironmentLoader struct {
KeyPrefix string
}
func NewEnvironmentLoader ¶ added in v0.3.0
func NewEnvironmentLoader() *EnvironmentLoader
func NewEnvironmentLoaderWithKeyPrefix ¶ added in v0.3.0
func NewEnvironmentLoaderWithKeyPrefix(keyPrefix string) *EnvironmentLoader
func (*EnvironmentLoader) Clone ¶
func (l *EnvironmentLoader) Clone() *EnvironmentLoader
func (*EnvironmentLoader) CloneLoader ¶ added in v0.4.0
func (l *EnvironmentLoader) CloneLoader() Loader
func (*EnvironmentLoader) Get ¶
func (l *EnvironmentLoader) Get(fieldSetKey, fieldKey string) (string, bool)
func (*EnvironmentLoader) GetMap ¶ added in v0.4.0
func (l *EnvironmentLoader) GetMap(fieldSetKey string, fieldKeys []string) map[string]string
func (*EnvironmentLoader) HelpString ¶
func (l *EnvironmentLoader) HelpString(fieldSetKey, fieldKey string) string
func (*EnvironmentLoader) Name ¶
func (l *EnvironmentLoader) Name() string
type Field ¶
type Field struct {
// Validator defines a function that runs during validation to check a value against validity constraints
Validator func(value any) error
// DefaultGenerator defines a function that creates a base value for a field
DefaultGenerator func() (any, error)
// Default defines a base value for a field
Default any
// Key is a required field that defines the field lookup value
Key string
// Type is a required field that defines the type of value the field contains
Type string
// Description defines a summary of the field contents
Description string
// Enumeration defines a list of acceptable inputs for the field value
Enumeration []any
// LoadConditions defines the conditions required for a field to load values
LoadConditions LoadConditions
// Required defines whether a field value must be set in order for the field to be valid
Required bool
// Sensitive identifies the field value as sensitive
Sensitive bool
// contains filtered or unexported fields
}
Field is a data structure that provides context for a configuration value
type FieldBuilder ¶ added in v0.3.0
type FieldBuilder struct {
// contains filtered or unexported fields
}
func FB ¶ added in v0.3.0
func FB() *FieldBuilder
func NewFieldBuilder ¶ added in v0.3.0
func NewFieldBuilder() *FieldBuilder
func (*FieldBuilder) Create ¶ added in v0.3.0
func (b *FieldBuilder) Create() *Field
func (*FieldBuilder) Default ¶ added in v0.3.0
func (b *FieldBuilder) Default(value any) *FieldBuilder
func (*FieldBuilder) DefaultGenerator ¶ added in v0.3.0
func (b *FieldBuilder) DefaultGenerator(value func() (any, error)) *FieldBuilder
func (*FieldBuilder) Description ¶ added in v0.3.0
func (b *FieldBuilder) Description(value string) *FieldBuilder
func (*FieldBuilder) Enumeration ¶ added in v0.3.0
func (b *FieldBuilder) Enumeration(value ...any) *FieldBuilder
func (*FieldBuilder) Key ¶ added in v0.3.0
func (b *FieldBuilder) Key(value string) *FieldBuilder
func (*FieldBuilder) LoadConditions ¶ added in v0.5.0
func (b *FieldBuilder) LoadConditions(value ...LoadCondition) *FieldBuilder
func (*FieldBuilder) Required ¶ added in v0.3.0
func (b *FieldBuilder) Required() *FieldBuilder
func (*FieldBuilder) Sensitive ¶ added in v0.3.0
func (b *FieldBuilder) Sensitive() *FieldBuilder
func (*FieldBuilder) Type ¶ added in v0.3.0
func (b *FieldBuilder) Type(value string) *FieldBuilder
func (*FieldBuilder) Validator ¶ added in v0.3.0
func (b *FieldBuilder) Validator(value func(fieldValue any) error) *FieldBuilder
type FieldCondition ¶
type FieldCondition struct {
Condition func(fieldValue any) (bool, error)
FieldSetKey string
FieldKey string
}
func (*FieldCondition) Clone ¶
func (c *FieldCondition) Clone() LoadCondition
func (*FieldCondition) FieldDependency ¶
func (c *FieldCondition) FieldDependency() (fieldSetKey, fieldKey string)
func (*FieldCondition) Validate ¶
func (c *FieldCondition) Validate() []error
type FieldConditionBuilder ¶ added in v0.3.0
type FieldConditionBuilder struct {
// contains filtered or unexported fields
}
func FCB ¶ added in v0.3.0
func FCB() *FieldConditionBuilder
func NewFieldConditionBuilder ¶ added in v0.3.0
func NewFieldConditionBuilder() *FieldConditionBuilder
func (*FieldConditionBuilder) Condition ¶ added in v0.3.0
func (b *FieldConditionBuilder) Condition(value func(fieldValue any) (bool, error)) *FieldConditionBuilder
func (*FieldConditionBuilder) Create ¶ added in v0.3.0
func (b *FieldConditionBuilder) Create() LoadCondition
func (*FieldConditionBuilder) FieldKey ¶ added in v0.3.0
func (b *FieldConditionBuilder) FieldKey(value string) *FieldConditionBuilder
func (*FieldConditionBuilder) FieldSetKey ¶ added in v0.3.0
func (b *FieldConditionBuilder) FieldSetKey(value string) *FieldConditionBuilder
type FieldSet ¶
type FieldSet struct {
Key string
LoadConditions LoadConditions
Fields Fields
// contains filtered or unexported fields
}
type FieldSetBuilder ¶ added in v0.3.0
type FieldSetBuilder struct {
// contains filtered or unexported fields
}
func FSB ¶ added in v0.3.0
func FSB() *FieldSetBuilder
func NewFieldSetBuilder ¶ added in v0.3.0
func NewFieldSetBuilder() *FieldSetBuilder
func (*FieldSetBuilder) Create ¶ added in v0.3.0
func (b *FieldSetBuilder) Create() *FieldSet
func (*FieldSetBuilder) Fields ¶ added in v0.3.0
func (b *FieldSetBuilder) Fields(value ...*Field) *FieldSetBuilder
func (*FieldSetBuilder) Key ¶ added in v0.3.0
func (b *FieldSetBuilder) Key(value string) *FieldSetBuilder
func (*FieldSetBuilder) LoadConditions ¶ added in v0.3.0
func (b *FieldSetBuilder) LoadConditions(value ...LoadCondition) *FieldSetBuilder
type Fields ¶ added in v0.2.0
type Fields []*Field
Fields is a slice of Field elements providing context for configuration values
type FlagLoader ¶
func NewFlagLoader ¶ added in v0.3.0
func NewFlagLoader() *FlagLoader
func NewFlagLoaderWithKeyPrefix ¶ added in v0.3.0
func NewFlagLoaderWithKeyPrefix(keyPrefix string) *FlagLoader
func (*FlagLoader) Clone ¶
func (l *FlagLoader) Clone() *FlagLoader
func (*FlagLoader) CloneLoader ¶ added in v0.4.0
func (l *FlagLoader) CloneLoader() Loader
func (*FlagLoader) GetMap ¶ added in v0.4.0
func (l *FlagLoader) GetMap(fieldSetKey string, fieldKeys []string) map[string]string
func (*FlagLoader) HelpString ¶
func (l *FlagLoader) HelpString(fieldSetKey, fieldKey string) string
func (*FlagLoader) Name ¶
func (l *FlagLoader) Name() string
type JSONFileLoader ¶ added in v0.4.0
type JSONFileLoader struct {
Decoder JSONUnmarshal
FilePaths []string
}
func NewJSONFileLoader ¶ added in v0.4.0
func NewJSONFileLoader() *JSONFileLoader
func NewJSONFileLoaderWithAttributes ¶ added in v0.4.0
func NewJSONFileLoaderWithAttributes(decoder JSONUnmarshal, filePaths ...string) *JSONFileLoader
func (*JSONFileLoader) Clone ¶ added in v0.4.0
func (l *JSONFileLoader) Clone() *JSONFileLoader
func (*JSONFileLoader) CloneLoader ¶ added in v0.4.0
func (l *JSONFileLoader) CloneLoader() Loader
func (*JSONFileLoader) Get ¶ added in v0.4.0
func (l *JSONFileLoader) Get(fieldSetKey, fieldKey string) (string, bool)
func (*JSONFileLoader) GetMap ¶ added in v0.4.0
func (l *JSONFileLoader) GetMap(fieldSetKey string, fieldKeys []string) map[string]string
func (*JSONFileLoader) HelpString ¶ added in v0.4.0
func (l *JSONFileLoader) HelpString(fieldSetKey, fieldKey string) string
func (*JSONFileLoader) Name ¶ added in v0.4.0
func (l *JSONFileLoader) Name() string
type JSONUnmarshal ¶ added in v0.4.0
type LoadCondition ¶
type LoadConditions ¶ added in v0.2.1
type LoadConditions []LoadCondition
type LoaderKeyOverride ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.