store: github.com/tucnak/store Index | Files

package store

import "github.com/tucnak/store"

Package store is a dead simple configuration manager for Go applications.

Index

Package Files

store.go

func Init Uses

func Init(application string)

Init sets up a unique application name that will be used for name of the configuration directory on the file system. By default, Store puts all the config data to to $XDG_CONFIG_HOME or $HOME on Linux systems and to %APPDATA% on Windows.

Beware: Store will panic on any sensitive calls unless you run Init inb4.

func Load Uses

func Load(path string, v interface{}) error

Load reads a configuration from `path` and puts it into `v` pointer. Store supports either JSON, TOML or YAML and will deduce the file format out of the filename (.json/.toml/.yaml). For other formats of custom extensions please you LoadWith.

Path is a full filename, including the file extension, e.g. "foobar.json". If `path` doesn't exist, Load will create one and emptify `v` pointer by replacing it with a newly created object, derived from type of `v`.

Load panics on unknown configuration formats.

func LoadWith Uses

func LoadWith(path string, v interface{}, um UnmarshalFunc) error

LoadWith loads the configuration using any unmarshaler at all.

func Register Uses

func Register(extension string, m MarshalFunc, um UnmarshalFunc)

Register is the way you register configuration formats, by mapping some file name extension to corresponding marshal and unmarshal functions. Once registered, the format given would be compatible with Load and Save.

func Save Uses

func Save(path string, v interface{}) error

Save puts a configuration from `v` pointer into a file `path`. Store supports either JSON, TOML or YAML and will deduce the file format out of the filename (.json/.toml/.yaml). For other formats of custom extensions please you LoadWith.

Path is a full filename, including the file extension, e.g. "foobar.json".

Save panics on unknown configuration formats.

func SaveWith Uses

func SaveWith(path string, v interface{}, m MarshalFunc) error

SaveWith saves the configuration using any marshaler at all.

func SetApplicationName Uses

func SetApplicationName(handle string)

SetApplicationName is DEPRECATED (use Init instead).

type MarshalFunc Uses

type MarshalFunc func(v interface{}) ([]byte, error)

MarshalFunc is any marshaler.

type UnmarshalFunc Uses

type UnmarshalFunc func(data []byte, v interface{}) error

UnmarshalFunc is any unmarshaler.

Package store imports 10 packages (graph). Updated 2017-09-10. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).