Documentation
¶
Overview ¶
Package config provides layered configuration management for the Core framework.
Configuration values are resolved in priority order: defaults -> file -> env -> flags. Values are stored in a YAML file at ~/.core/config.yaml by default.
Keys use dot notation for nested access:
cfg.Set("dev.editor", "vim")
var editor string
cfg.Get("dev.editor", &editor)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
Load reads a YAML configuration file from the given medium and path. Returns the parsed data as a map, or an error if the file cannot be read or parsed.
func LoadEnv ¶
LoadEnv parses environment variables with the given prefix and returns them as a flat map with dot-notation keys.
For example, with prefix "CORE_CONFIG_":
CORE_CONFIG_FOO_BAR=baz -> {"foo.bar": "baz"}
CORE_CONFIG_EDITOR=vim -> {"editor": "vim"}
func NewConfigService ¶
NewConfigService creates a new config service factory for the Core framework. Register it with core.WithService(config.NewConfigService).
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config implements the core.Config interface with layered resolution. Values are resolved in order: defaults -> file -> env -> flags.
func New ¶
New creates a new Config instance with the given options. If no medium is provided, it defaults to io.Local. If no path is provided, it defaults to ~/.core/config.yaml.
func (*Config) Get ¶
Get retrieves a configuration value by dot-notation key and stores it in out. The out parameter must be a pointer to the target type. Returns an error if the key is not found.
type Option ¶
type Option func(*Config)
Option is a functional option for configuring a Config instance.
func WithMedium ¶
WithMedium sets the storage medium for configuration file operations.
type Service ¶
type Service struct {
*core.ServiceRuntime[ServiceOptions]
// contains filtered or unexported fields
}
Service wraps Config as a framework service with lifecycle support.
type ServiceOptions ¶
type ServiceOptions struct {
// Path overrides the default config file path.
Path string
// Medium overrides the default storage medium.
Medium io.Medium
}
ServiceOptions holds configuration for the config service.