mirror of
https://github.com/taigrr/jety.git
synced 2026-04-02 03:19:03 -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:
21
README.md
21
README.md
@@ -68,16 +68,25 @@ timeout = "30s"
|
||||
client_id = "abc123"
|
||||
```
|
||||
|
||||
Access nested values using `GetStringMap` and type assertions:
|
||||
Use `Sub()` to get a scoped ConfigManager for a nested section:
|
||||
|
||||
```go
|
||||
cloud := jety.Sub("services")
|
||||
if cloud != nil {
|
||||
inner := cloud.Sub("cloud")
|
||||
if inner != nil {
|
||||
varValue := inner.GetString("var") // "xyz"
|
||||
timeout := inner.GetDuration("timeout") // 30s
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Or access nested values directly with `GetStringMap` and type assertions:
|
||||
|
||||
```go
|
||||
services := jety.GetStringMap("services")
|
||||
cloud := services["cloud"].(map[string]any)
|
||||
varValue := cloud["var"].(string) // "xyz"
|
||||
|
||||
// For deeper nesting
|
||||
auth := cloud["auth"].(map[string]any)
|
||||
clientID := auth["client_id"].(string) // "abc123"
|
||||
```
|
||||
|
||||
### Environment Variable Overrides
|
||||
@@ -124,6 +133,8 @@ export MYAPP_SERVICES_CLOUD_VAR=override_value
|
||||
| ------------------------ | ------------------------ |
|
||||
| `Set(key, value)` | Set a value |
|
||||
| `SetDefault(key, value)` | Set a default value |
|
||||
| `Delete(key)` | Remove a key |
|
||||
| `Sub(key)` | Get scoped sub-config |
|
||||
| `Get(key)` | Get raw value |
|
||||
| `GetString(key)` | Get as string |
|
||||
| `GetInt(key)` | Get as int |
|
||||
|
||||
Reference in New Issue
Block a user