Documentation
¶
Overview ¶
Package config decodes environment-backed settings into typed Go structs.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
func Decode[T any](lookup LookupFunc) (T, error)
Decode decodes lookup values into a typed configuration struct.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error reports one or more configuration problems.
type LookupFunc ¶
LookupFunc looks up a configuration value by key.
func FromMap ¶
func FromMap(values map[string]string) LookupFunc
FromMap returns a lookup function backed by values.
type Option ¶
type Option func(*options)
Option configures Load.
func WithEnvironment ¶
WithEnvironment configures the environment-specific file suffix.
func WithLookup ¶
func WithLookup(lookup LookupFunc) Option
WithLookup configures the highest-priority lookup source.
func WithoutEnvFiles ¶
func WithoutEnvFiles() Option
WithoutEnvFiles disables environment file loading.
type Problem ¶
type Problem struct {
// Field is the exported struct field name, when the problem is tied to a field.
Field string
// Key is the environment lookup key used for the field.
Key string
// Message explains the validation or parsing failure.
Message string
}
Problem describes one invalid or missing configuration value.
type Secret ¶
type Secret string
Secret stores a sensitive configuration value and redacts itself in logs.
Example ¶
secret := Secret("postgres://localhost/ohm")
fmt.Println(secret)
fmt.Println(secret.Reveal())
Output: [REDACTED] postgres://localhost/ohm
func (Secret) MarshalJSON ¶
MarshalJSON returns a redacted JSON string.
func (*Secret) UnmarshalText ¶
UnmarshalText stores text as a secret value.