Documentation
¶
Overview ¶
Package config provides explicit, typed environment configuration without reflection. A Reader accumulates all configuration errors for one useful startup failure instead of panicking at the first missing value.
Index ¶
- type FieldError
- type Reader
- func (reader *Reader) Bool(key string, fallback bool) bool
- func (reader *Reader) Duration(key string, fallback time.Duration) time.Duration
- func (reader *Reader) Err() error
- func (reader *Reader) Int(key string, fallback int) int
- func (reader *Reader) LoadFile(path string) error
- func (reader *Reader) Required(key string) string
- func (reader *Reader) String(key, fallback string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FieldError ¶ added in v0.23.0
FieldError identifies an invalid configuration field without retaining its supplied value or the value-bearing conversion error. Key is the name passed by application code, not an untrusted field name read from a configuration file. Rule is one of required, integer, boolean, or duration for Reader errors. Errors accumulated by Reader remain discoverable with errors.As.
func (*FieldError) Error ¶ added in v0.23.0
func (problem *FieldError) Error() string
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader holds a snapshot of configuration and accumulates typed conversion errors. Construct a Reader with FromEnvironment or FromMap before loading files.
func FromEnvironment ¶
func FromEnvironment() *Reader