Documentation
¶
Overview ¶
Package config provides an env-only configuration loader for paper-board services.
MustBind reads environment variables onto a service-defined struct via reflection over `env`, `default`, and `validate` struct tags. After binding, validator/v10 runs Struct() on the destination. Required fields with no env or default cause MustBind to log to stderr and exit non-zero.
Flags and config files are intentionally unsupported. Service binaries MAY accept positional/flag args via cobra for one-shot operations (e.g. migrator subcommands), but those flags MUST NOT override Config fields.
Example:
type Config struct {
DatabaseURL string `env:"DATABASE_URL" validate:"required,url"`
ServerPort int `env:"SERVER_PORT" default:"8080" validate:"gte=1,lte=65535"`
LogLevel string `env:"LOG_LEVEL" default:"info" validate:"oneof=debug info warn error"`
Timeout time.Duration `env:"TIMEOUT" default:"30s"`
Tags []string `env:"TAGS" default:"a,b,c"`
Debug bool `env:"DEBUG" default:"false"`
}
cfg := config.MustBind[Config]()
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.