Documentation
¶
Overview ¶
Package configuration provides functions to save and read configuration structures.
Configuration files are read from/save to XDG_CONFIG_HOME/<executable name>/config.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInterfaceConversion indicates that supplied T is different from cached type. ErrInterfaceConversion = errors.New("interface conversion") // ErrYAMLMarshal indicates error marshalling supplied data to YAML. ErrYAMLMarshal = errors.New("unable to (un)marshal data to/from yaml") )
Functions ¶
func Get ¶
Get returns the configuration data for the supplied configuration struct type T, caching it after first retrieval. Error will be returned if:
- both XDG_CONFIG_HOME and HOME env vars not set.
- user lacks permission to read from XDG_CONFIG_HOME/<executable name>/config.
- on subsequent calls, supplied T must be same as original T.
- config file cannot be converted to supplied T.
func Save ¶
Save saves the provided struct as a yaml config file in $XDG_CONFIG_HOME/executable name/ and updates the cache. Config dir and file willl be created if it dosen't exist Error will be returned if:
- both XDG_CONFIG_HOME and HOME env vars not set.
- user lacks permission to write to XDG_CONFIG_HOME/<executable name>/.
- supplied strut T cannot be marshalled to yaml.
Types ¶
This section is empty.