mirror of
https://github.com/taigrr/jety.git
synced 2026-04-01 19:08:58 -07:00
feat(api): add Delete and Sub methods, update CI workflows
- Add Delete(key) to remove keys from all config layers - Add Sub(key) to get a scoped ConfigManager for nested sections - Update CodeQL workflow actions to v4/v5/v3 - Update govulncheck workflow checkout to v4 - Remove boilerplate comments from CodeQL workflow - Add comprehensive tests for both new methods - Update README with Sub() usage example and API docs
This commit is contained in:
13
setters.go
13
setters.go
@@ -28,6 +28,19 @@ func (c *ConfigManager) Set(key string, value any) {
|
||||
c.combinedConfig[lower] = ConfigMap{Key: key, Value: value}
|
||||
}
|
||||
|
||||
// Delete removes a key from all configuration layers (overrides, file,
|
||||
// defaults) and rebuilds the combined configuration. Environment variables
|
||||
// are not affected since they are loaded from the process environment.
|
||||
func (c *ConfigManager) Delete(key string) {
|
||||
c.mutex.Lock()
|
||||
lower := strings.ToLower(key)
|
||||
delete(c.overrideConfig, lower)
|
||||
delete(c.fileConfig, lower)
|
||||
delete(c.defaultConfig, lower)
|
||||
delete(c.combinedConfig, lower)
|
||||
c.mutex.Unlock()
|
||||
}
|
||||
|
||||
func (c *ConfigManager) SetDefault(key string, value any) {
|
||||
c.mutex.Lock()
|
||||
defer c.mutex.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user