configx

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package configx loads layered configuration — TOML files, an optional local overlay, environment-variable overrides, and defaults — into typed structs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(envPrefix string, cfgs ...Configurable) error

Configure creates a single Reader and calls ReadConfig on each Configurable in order. Use NewViperConfigReader when you need to reuse the same parsed config across multiple calls.

Types

type Configurable

type Configurable interface {
	ReadConfig(Reader) error
}

Configurable is implemented by any type that can populate itself from a Reader. ReadConfig is called on each registered value in order.

type Reader

type Reader interface {
	SetDefault(key string, value any)
	Read(key string, dest any) error
	ReadMap(key string) map[string]any
	ReadAll(dest any) error
}

Reader wraps a reader instance and exposes config-reading operations to Configurable implementations.

func NewViperConfigReader

func NewViperConfigReader(envPrefix string) (Reader, error)

NewViperConfigReader creates a Reader. Use this to hold a single reader across multiple Configure calls (e.g. in App.configReader) so the config file is only read once.

Jump to

Keyboard shortcuts

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