https://github.com/spurge/goset
Async settings library for go
https://github.com/spurge/goset
async golang goroutine json settings
Last synced: 6 months ago
JSON representation
Async settings library for go
- Host: GitHub
- URL: https://github.com/spurge/goset
- Owner: spurge
- License: mit
- Created: 2017-11-12T20:06:15.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-02T20:47:58.000Z (over 7 years ago)
- Last Synced: 2024-06-20T12:42:57.270Z (about 2 years ago)
- Topics: async, golang, goroutine, json, settings
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# goset
`import "github.com/spurge/goset"`
* [Overview](#pkg-overview)
* [Index](#pkg-index)
* [Subdirectories](#pkg-subdirectories)
## Overview
Package goset is a settings library that provides async loading of settings
with a handy getter.
You can load and set with the same instance and it'll merge all your settings.
Event though all Load and Set actions are running async, they'll merge your
settings in the same order as you typed them.
Example of use:
settings := Settings.New()
// Set some default values
settings.Set(map[string]interfaces{}{
"some-key": map[string]interfaces{}{
"hello": "world",
},
})
// Then load some json data
// For now, goset does only sopport JSON.
settings.Load("some-file.json")
// Fetch some values
val, err := settings.Get("some-key.hello")
// You can even chain them ...
settings.Set(...).Load("file")
## Index
* [type Settings](#Settings)
* [func New() Settings](#New)
* [func (s *Settings) Get(path string) (interface{}, error)](#Settings.Get)
* [func (s *Settings) Load(filename string) *Settings](#Settings.Load)
* [func (s *Settings) Set(values map[string]interface{}) *Settings](#Settings.Set)
#### Package files
[goset.go](/src/github.com/spurge/goset/goset.go) [util.go](/src/github.com/spurge/goset/util.go)
## type [Settings](/src/target/goset.go?s=763:920#L33)
``` go
type Settings struct {
// contains filtered or unexported fields
}
```
### func [New](/src/target/goset.go?s=962:981#L43)
``` go
func New() Settings
```
Create a new goset settings instance
### func (\*Settings) [Get](/src/target/goset.go?s=1402:1458#L62)
``` go
func (s *Settings) Get(path string) (interface{}, error)
```
Get values from your settings
### func (\*Settings) [Load](/src/target/goset.go?s=1108:1158#L50)
``` go
func (s *Settings) Load(filename string) *Settings
```
Load local JSON file and merge it's values into the settings instance
### func (\*Settings) [Set](/src/target/goset.go?s=1259:1322#L56)
``` go
func (s *Settings) Set(values map[string]interface{}) *Settings
```
Set and merge values into the settings instance
- - -
Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md)