Documentation
¶
Overview ¶
Package dexconfig loads configuration from environment variables into a struct using `env` struct tags. It supports nested structs, pointer-to-struct fields, default values, required fields, slices, maps, custom unmarshalers, and time.Duration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadConfig ¶
LoadConfig populates the struct pointed to by c from environment variables. c must be a non-nil pointer to a struct.
Types ¶
type FieldError ¶ added in v1.2.0
FieldError describes a failure to load a single struct field.
func (*FieldError) Error ¶ added in v1.2.0
func (e *FieldError) Error() string
func (*FieldError) Unwrap ¶ added in v1.2.0
func (e *FieldError) Unwrap() error
type LookupFunc ¶ added in v1.2.0
LookupFunc resolves an environment variable name to its value and a bool indicating whether the variable was set. It mirrors os.LookupEnv.
type Option ¶ added in v1.2.0
type Option func(*options)
Option configures LoadConfig behavior.
func WithLookup ¶ added in v1.2.0
func WithLookup(fn LookupFunc) Option
WithLookup overrides the function used to resolve environment variables. The default is os.LookupEnv.
func WithPrefix ¶ added in v1.2.0
WithPrefix sets a prefix that is prepended (with an underscore) to every environment variable key resolved during loading.
func WithSeparator ¶ added in v1.2.0
WithSeparator overrides the separator used when parsing slice and map values. The default is ",".
func WithTagName ¶ added in v1.2.0
WithTagName overrides the struct tag name used to read configuration directives. The default is "env".