appsettings

Simple Hierarchical Key/Value Store for Simple Go Runtime App Setting Storage

MIT License

Stars
3
Committers
2

AppSettings

A hierarchical key value store for persisting simple runtime options in Go applications.

Example

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

$ 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 and execute the following command, first replacing {your-file} with the path to your actual database file.

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