mirror of
https://github.com/taigrr/jety.git
synced 2026-04-02 03:19:03 -07:00
feat: add IsSet, AllKeys, AllSettings; fix env precedence for file-only keys
- collapse() now applies env vars for keys present in fileConfig, not just defaultConfig. Previously, env vars couldn't override file values unless a default was also set for that key. - SetDefault no longer pollutes overrideConfig; it correctly resolves the value by checking override > env > file > default. - Remove unused explicitDefaults field and UseExplicitDefaults method. - Add IsSet, AllKeys, AllSettings methods + package-level wrappers. - Add missing package-level wrappers: Get, SetBool, SetString, SetConfigDir, WithEnvPrefix. - Add tests for all new methods and the env-over-file-without-default fix.
This commit is contained in:
32
default.go
32
default.go
@@ -67,3 +67,35 @@ func GetStringMap(key string) map[string]any {
|
||||
func GetStringSlice(key string) []string {
|
||||
return defaultConfigManager.GetStringSlice(key)
|
||||
}
|
||||
|
||||
func Get(key string) any {
|
||||
return defaultConfigManager.Get(key)
|
||||
}
|
||||
|
||||
func SetBool(key string, value bool) {
|
||||
defaultConfigManager.SetBool(key, value)
|
||||
}
|
||||
|
||||
func SetString(key string, value string) {
|
||||
defaultConfigManager.SetString(key, value)
|
||||
}
|
||||
|
||||
func SetConfigDir(path string) {
|
||||
defaultConfigManager.SetConfigDir(path)
|
||||
}
|
||||
|
||||
func WithEnvPrefix(prefix string) *ConfigManager {
|
||||
return defaultConfigManager.WithEnvPrefix(prefix)
|
||||
}
|
||||
|
||||
func IsSet(key string) bool {
|
||||
return defaultConfigManager.IsSet(key)
|
||||
}
|
||||
|
||||
func AllKeys() []string {
|
||||
return defaultConfigManager.AllKeys()
|
||||
}
|
||||
|
||||
func AllSettings() map[string]any {
|
||||
return defaultConfigManager.AllSettings()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user