Skip to content

spurge/goset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goset

import "github.com/spurge/goset"

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")

goset.go util.go

type Settings struct {
    // contains filtered or unexported fields
}
func New() Settings

Create a new goset settings instance

func (*Settings) Get

func (s *Settings) Get(path string) (interface{}, error)

Get values from your settings

func (*Settings) Load

func (s *Settings) Load(filename string) *Settings

Load local JSON file and merge it's values into the settings instance

func (*Settings) Set

func (s *Settings) Set(values map[string]interface{}) *Settings

Set and merge values into the settings instance


Generated by godoc2md

Releases

No releases published

Packages

No packages published

Languages