config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package config loads explicit, typed application configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dump

func Dump(v any) ([]byte, error)

Dump returns JSON with secret-tagged and sensitive-name fields redacted, recursively.

func GetBool

func GetBool(k string, f bool) bool

GetBool reads a boolean environment variable, returning the fallback on invalid input.

func GetDuration

func GetDuration(k string, f time.Duration) time.Duration

func GetInt

func GetInt(k string, f int) int

GetInt reads an integer environment variable, returning the fallback on invalid input.

func GetString

func GetString(k, f string) string

GetString reads an environment variable, returning the fallback when absent.

func GetStringSlice

func GetStringSlice(k string, f []string) []string

GetStringSlice reads comma-separated environment values or copies the fallback.

func Load

func Load(dst any, options ...Options) error

Load updates a struct only after all conversions and validation succeed. Tags are env, default, required, secret.

func Validate

func Validate(value any) error

Validate checks required tags recursively and runs nested/root validation hooks after field checks.

Types

type Options

type Options struct {
	Environment  string
	Overrides    map[string]io.Reader
	Values       map[string]string
	MaxFileBytes int64
	Prefix       string
	Lookup       func(string) (string, bool)
	File         io.Reader
	Validate     func(any) error
}

Options controls loading. Precedence is defaults, existing values/file, environment.

Jump to

Keyboard shortcuts

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