https://github.com/donatj/appsettings
Simple Hierarchical Key/Value Store for Simple Go Runtime App Setting Storage
https://github.com/donatj/appsettings
appsettings
Last synced: about 1 year ago
JSON representation
Simple Hierarchical Key/Value Store for Simple Go Runtime App Setting Storage
- Host: GitHub
- URL: https://github.com/donatj/appsettings
- Owner: donatj
- License: mit
- Created: 2014-12-13T06:26:21.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-05-06T16:55:02.000Z (about 2 years ago)
- Last Synced: 2025-03-29T23:11:57.099Z (about 1 year ago)
- Topics: appsettings
- Language: Go
- Homepage:
- Size: 66.4 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# AppSettings
[](https://github.com/donatj/appsettings/actions/workflows/ci.yml)
[](https://godoc.org/github.com/donatj/appsettings)
A hierarchical key value store for persisting simple runtime options in Go applications.
## Example
```go
s := appsettings.NewAppSettings("settings.json")
t := s.GetTree("user-settings")
//set
t.SetString("pizza", "pie")
t.SetInt("how-many-pugs", 349)
//read
if v, err := t.GetInt("how-many-pugs"); err == nil {
log.Println(v)
}
if v, err = t.GetString("pizza"); err == nil {
log.Println(v)
}
s.Persist()
```
## CLI Tool Installation
### From Source
```bash
$ go install github.com/donatj/appsettings/cmd/appsettings@latest
```
## Migration from v0.0.1
The JSON format for the early Alpha changed. To migrate your existing data compatibly to the more modern format, you can use [jq](https://stedolan.github.io/jq/) and execute the following command, first replacing `{your-file}` with the path to your actual database file.
```bash
jq '.Tree |= with_entries(.value = {Leaves: .value} ) | . + {Branches: .Tree} | del(.Tree)' < {your-file} > tmp && mv tmp {your-fie}
```
## Documentation
Documentation can be found a godoc:
https://godoc.org/github.com/donatj/appsettings