Documentation ¶
Overview ¶
Package store is a dead simple configuration manager for Go applications.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadWith ¶
func LoadWith(path string, v interface{}, um UnmarshalFunc) error
LoadWith loads the configuration using any unmarshaler at all.
func Register ¶
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 SaveWith ¶
func SaveWith(path string, v interface{}, m MarshalFunc) error
SaveWith saves the configuration using any marshaler at all.
Types ¶
type MarshalFunc ¶
MarshalFunc is any marshaler.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) Load ¶
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`.
func (*Store) Save ¶
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".
type UnmarshalFunc ¶
UnmarshalFunc is any unmarshaler.