config

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsProduction added in v1.0.6

func IsProduction(env string) bool

IsProduction returns true when env is production-like.

func SplitCSV added in v1.0.6

func SplitCSV(input string) []string

SplitCSV splits a comma-separated string into a list of trimmed values.

Types

type Config

type Config struct {
	Addr           string `env:"API_ADDR"`         // host:port|:port
	DatabaseURL    string `env:"DATABASE_URL"`     // required
	LogLevel       string `env:"LOG_LEVEL"`        // debug|info|warn|error
	MigrateOnStart bool   `env:"MIGRATE_ON_START"` // true|false
	MigrationsDir  string `env:"MIGRATIONS_DIR"`   // plain - means use embedded
	Env            string `env:"ENV"`              // development|staging|production

	// Optional rate-limit bypass for test/dev environments.
	RateLimitSkipEnabled bool   `env:"RATE_LIMIT_SKIP_ENABLED"` // true|false
	RateLimitSkipHeader  string `env:"RATE_LIMIT_SKIP_HEADER"`  // header name
}

func LoadFromEnv added in v1.0.6

func LoadFromEnv(loader *Loader) (Config, error)

LoadFromEnv loads config from environment using an optional loader.

func MustLoadFromEnv

func MustLoadFromEnv() Config

MustLoadFromEnv loads config or panics if required values are missing.

type Loader added in v1.0.6

type Loader struct {
	// contains filtered or unexported fields
}

Loader reads env vars with defaults and aggregates errors.

func NewLoader added in v1.0.6

func NewLoader() *Loader

NewLoader creates a loader backed by the default env adapter.

func (*Loader) Bool added in v1.0.6

func (l *Loader) Bool(key string, def bool) bool

Bool reads a bool env var with a default.

func (*Loader) CSV added in v1.0.6

func (l *Loader) CSV(key string) []string

CSV reads a comma-separated env var into a slice.

func (*Loader) Duration added in v1.0.6

func (l *Loader) Duration(key string, def time.Duration) time.Duration

Duration reads a duration env var with a default.

func (*Loader) Err added in v1.0.6

func (l *Loader) Err() error

Err returns aggregated errors, if any.

func (*Loader) Int added in v1.0.6

func (l *Loader) Int(key string, def int) int

Int reads an int env var with a default.

func (*Loader) Require added in v1.0.6

func (l *Loader) Require(key string) string

Require returns the env var or records an error if missing.

func (*Loader) String added in v1.0.6

func (l *Loader) String(key, def string) string

String reads a string env var with a default.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL