e5.0.0 Tests added, bug fixes.

This commit is contained in:
2025-07-19 19:05:17 -04:00
parent 5a58db6108
commit e9b55063ff
19 changed files with 2143 additions and 339 deletions

View File

@ -1,4 +1,4 @@
// File: lixenwraith/config/config.go
// FILE: lixenwraith/config/config.go
// Package config provides thread-safe configuration management for Go applications
// with support for multiple sources: TOML files, environment variables, command-line
// arguments, and default values with configurable precedence.
@ -52,6 +52,7 @@ type structCache struct {
// 2. As a source for a type-safe struct, populated via BuildAndScan() or AsStruct()
type Config struct {
items map[string]configItem
tagName string
mutex sync.RWMutex
options LoadOptions // Current load options
fileData map[string]any // Cached file data
@ -69,6 +70,7 @@ type Config struct {
func New() *Config {
return &Config{
items: make(map[string]configItem),
tagName: "toml",
options: DefaultLoadOptions(),
fileData: make(map[string]any),
envData: make(map[string]any),
@ -157,6 +159,10 @@ func (c *Config) SetSource(path string, source Source, value any) error {
return fmt.Errorf("path %s is not registered", path)
}
if str, ok := value.(string); ok && len(str) > MaxValueSize {
return ErrValueSize
}
if item.values == nil {
item.values = make(map[Source]any)
}