Documentation
¶
Index ¶
- func LoadConfig[T any](defaults T, flags *pflag.FlagSet, opts ...LoadOption) (*T, error)
- type Config
- type EnvSource
- type EnvSourceOption
- type FileSource
- type FileSourceOption
- type FlagSource
- type FlagSourceOption
- type LoadOption
- type Option
- type Source
- type Value
- type ValueSource
- type ValueSourceOption
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadConfig ¶ added in v0.0.2
func LoadConfig[T any](defaults T, flags *pflag.FlagSet, opts ...LoadOption) (*T, error)
Types ¶
type Config ¶
type EnvSource ¶ added in v0.0.2
type EnvSource struct {
// contains filtered or unexported fields
}
EnvSource provides environment variable configuration
func NewEnvSource ¶ added in v0.0.2
func NewEnvSource(opts ...EnvSourceOption) (*EnvSource, error)
NewEnvSource creates a new EnvSource with the given prefix
type EnvSourceOption ¶ added in v0.0.2
func WithEnvNameMapping ¶ added in v0.0.3
func WithEnvNameMapping(nameMappings map[string]string) EnvSourceOption
WithEnvNameMapping allows setting nameMappings for environment variable names
func WithEnvPrefix ¶ added in v0.0.2
func WithEnvPrefix(prefix string) EnvSourceOption
WithEnvPrefix allows setting a prefix for environment variable names
type FileSource ¶ added in v0.0.2
type FileSource struct {
// contains filtered or unexported fields
}
FileSource provides file-based configuration
func NewFileSource ¶ added in v0.0.2
func NewFileSource(opts ...FileSourceOption) (*FileSource, error)
NewFileSource creates a new FileSource with the given files
func (*FileSource) Load ¶ added in v0.0.2
func (fs *FileSource) Load() (map[string]any, error)
Load returns the configuration data from files
func (*FileSource) Watch ¶ added in v0.0.2
func (fs *FileSource) Watch() (Watcher, error)
type FileSourceOption ¶ added in v0.0.2
type FileSourceOption func(*FileSource) error
func WithFilePath ¶ added in v0.0.2
func WithFilePath(files ...string) FileSourceOption
type FlagSource ¶ added in v0.0.2
type FlagSource struct {
// contains filtered or unexported fields
}
FlagSource provides command-line flag configuration
func NewFlagSource ¶ added in v0.0.2
func NewFlagSource(flags *pflag.FlagSet, opts ...FlagSourceOption) (*FlagSource, error)
NewFlagSource creates a new FlagSource with the given flag set
func (*FlagSource) Load ¶ added in v0.0.2
func (fs *FlagSource) Load() (map[string]any, error)
Load returns the configuration data from command-line flags
func (*FlagSource) Watch ¶ added in v0.0.2
func (fs *FlagSource) Watch() (Watcher, error)
type FlagSourceOption ¶ added in v0.0.2
type FlagSourceOption func(*FlagSource) error
type LoadOption ¶ added in v0.0.2
type LoadOption func(*loadOptions)
func WithDefaultValueOptions ¶ added in v0.0.2
func WithDefaultValueOptions(defaults any) LoadOption
func WithEnvOptions ¶ added in v0.0.2
func WithEnvOptions(opts ...EnvSourceOption) LoadOption
func WithFileOptions ¶ added in v0.0.2
func WithFileOptions(opts ...FileSourceOption) LoadOption
func WithFlagOptions ¶ added in v0.0.2
func WithFlagOptions(opts ...FlagSourceOption) LoadOption
func WithValueTagOptions ¶ added in v0.0.3
func WithValueTagOptions(opts ...ValueSourceOption) LoadOption
type Source ¶
type Source interface {
// Load returns the configuration data from this source
Load() (map[string]any, error)
Watch() (Watcher, error)
}
Source defines the interface for configuration sources
type ValueSource ¶ added in v0.0.2
type ValueSource struct {
// contains filtered or unexported fields
}
ValueSource provides default configuration values
func NewValueSourceFromMap ¶ added in v0.0.2
func NewValueSourceFromMap(value map[string]any) (*ValueSource, error)
NewValueSourceFromMap creates a new ValueSource with the given value
func NewValueSourceFromStruct ¶ added in v0.0.2
func NewValueSourceFromStruct(defaults any, opts ...ValueSourceOption) (*ValueSource, error)
NewValueSourceFromStruct creates a ValueSource from a struct
func (*ValueSource) Load ¶ added in v0.0.2
func (ds *ValueSource) Load() (map[string]any, error)
Load returns the default configuration data
func (*ValueSource) Watch ¶ added in v0.0.2
func (ds *ValueSource) Watch() (Watcher, error)
type ValueSourceOption ¶ added in v0.0.3
type ValueSourceOption func(*ValueSource) error
func WithValueTag ¶ added in v0.0.3
func WithValueTag(tag string) ValueSourceOption
WithValueTag sets the tag used for struct fields in ValueSource