https://github.com/kusokaihatsusha/easy_settings
Package for savings JSON settings to single-alone database (type Bolt) with use minimal counts of lines code.
https://github.com/kusokaihatsusha/easy_settings
bolt boltdb easy-to-use json settings wrapper-library
Last synced: 3 months ago
JSON representation
Package for savings JSON settings to single-alone database (type Bolt) with use minimal counts of lines code.
- Host: GitHub
- URL: https://github.com/kusokaihatsusha/easy_settings
- Owner: KusoKaihatsuSha
- License: mit
- Created: 2021-03-22T16:21:48.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-07-08T04:49:54.000Z (about 4 years ago)
- Last Synced: 2025-06-30T09:07:01.651Z (about 1 year ago)
- Topics: bolt, boltdb, easy-to-use, json, settings, wrapper-library
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://opensource.org/licenses/MIT) [](https://godoc.org/github.com/KusoKaihatsuSha/easy_settings) [](https://goreportcard.com/report/github.com/KusoKaihatsuSha/easy_settings)
# Source package for easy saving settings
Package for savings JSON settings to single-alone database (type Bolt) with use minimal counts of lines code.
### Add to use
```
$ go get github.com/KusoKaihatsuSha/easy_settings.git
```
### Usage example
In example will be created database `data.db` in same folder and create `data_group.json` as export settings from database
```go
package main
import (
"fmt"
es "github.com/KusoKaihatsuSha/easy_settings"
)
func main() {
es.Pack("group").Item("test011").Add("id001", "001").Add("id002", "002")
es.Pack("group").Item("test012").Add("id003", "003")
es.Pack("group").Item("test021").Add("id004", "004")
fmt.Println(es.Pack("group").Item("test011", true).Get("id001"))
fmt.Println(es.Pack("group").Item("test01", true).Get("id", true))
fmt.Println(es.Pack("group").Item("test", true).Get("id", true))
es.Pack("group").Item("test", true).SaveJson()
}
```
### Output file if using `SaveJson()`
```json
{
"ID": "4t81omdwfn8Am65c",
"Name": "group",
"Items": [
{
"Parent": null,
"Name": "test011",
"ID": "5pqsia7a5vC5lv67",
"Values": [
{
"Key": "id001",
"Value": "001"
},
{
"Key": "id002",
"Value": "002"
}
]
},
{
"Parent": null,
"Name": "test012",
"ID": "106UtcxTnn1w5Ux6",
"Values": [
{
"Key": "id003",
"Value": "003"
}
]
},
{
"Parent": null,
"Name": "test021",
"ID": "oeBj70fWn8gnjj65",
"Values": [
{
"Key": "id004",
"Value": "004"
}
]
}
],
"Db": null,
"Uniq": false
}
```