Documentation
¶
Overview ¶
Package confiq is a Go package for populating structs from structured data formats such JSON, TOML, YAML or Env.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidTarget = errors.New("target must be non-nil pointer to a slice, map or struct that has at least one exported field with a the configured tag") ErrNoTargetFieldsAreSet = errors.New("none of the target fields were set from config values") )
Collection of decode errors.
var ( ErrCannotOpenConfig = errors.New("cannot open config") ErrCannotLoadConfig = errors.New("cannot load config") )
Collection of loader errors.
Functions ¶
func AsStrict ¶
func AsStrict() decodeOption
AsStrict sets the decoder to decode the configuration values as if all fields are set to strict.
func FromPrefix ¶
func FromPrefix(prefix string) decodeOption
FromPrefix sets the prefix to be used when decoding configuration values into the target struct.
func WithPrefix ¶
func WithPrefix(prefix string) loadOption
WithPrefix sets the prefix to be used when loading configuration values into the ConfigSet.
Types ¶
type ConfigSet ¶
type ConfigSet struct {
// contains filtered or unexported fields
}
ConfigSet is a configuration set that can be used to load and decode configuration values into a struct.
func New ¶
func New(options ...configSetOption) *ConfigSet
New creates a new ConfigSet with the given options.
func (*ConfigSet) Load ¶
func (c *ConfigSet) Load(valueContainer IValueContainer, options ...loadOption) error
func (*ConfigSet) LoadRawValue ¶
LoadRawValue loads a raw value into the config set. The value must be a map[string]any or a slice of any.
type ConfigSetOptions ¶
type ConfigSetOptions []loadOption
ConfigSetOptions is exposed so that functions which wrap the New function can make adding the WithTag option easier.
type DecodeOptions ¶
type DecodeOptions []decodeOption
DecodeOptions is exposed so that functions which wrap the Decode function can make adding the AsStrict and FromPrefix options easier.
type IValueContainer ¶
type LoadOptions ¶
type LoadOptions []loadOption
LoadOptions is exposed so that functions which wrap the Load function can make adding the WithPrefix option easier.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
_examples
|
|
loaders
|
|
env
Package confiqenv allows confiq values to be loaded from Env format.
|
Package confiqenv allows confiq values to be loaded from Env format. |
json
Package confiqjson allows confiq values to be loaded from JSON format.
|
Package confiqjson allows confiq values to be loaded from JSON format. |
toml
Package confiqtoml allows confiq values to be loaded from TOML format.
|
Package confiqtoml allows confiq values to be loaded from TOML format. |
yaml
Package confiqyaml allows confiq values to be loaded from YAML format.
|
Package confiqyaml allows confiq values to be loaded from YAML format. |