Documentation
¶
Overview ¶
Package config provides the repository for configuration and preferences.
Index ¶
- Constants
- func AppearanceAdd(name string, value EntryValue)
- func DirPath() string
- func MarshalToFile(file string, from interface{}) error
- func PrettyMarshal(dst io.Writer, v interface{}) error
- func RegisterConfig(filename string, jsonValue interface{})
- func Restore()
- func Save() error
- func SaveToFile(file string, v []byte) error
- func Sections() (sects [sectionLen][]Entry)
- func UnmarshalFromFile(file string, to interface{}) error
- type Entry
- type EntryValue
- type Section
- type SectionEntries
- type Updaters
Constants ¶
const ConfigFile = "config.json"
Variables ¶
This section is empty.
Functions ¶
func AppearanceAdd ¶
func AppearanceAdd(name string, value EntryValue)
func MarshalToFile ¶
MarshalToFile marshals the given interface into the given filename. The filename will be prepended with the config directory.
func PrettyMarshal ¶
PrettyMarshal pretty marshals v into dst as formatted JSON.
func RegisterConfig ¶
func RegisterConfig(filename string, jsonValue interface{})
RegisterConfig adds the config filename into the registry of value pointers to unmarshal configs to.
func Restore ¶
func Restore()
Restore the global config. IsNotExist is not an error and will not be logged.
func SaveToFile ¶
SaveToFile saves the given bytes into the given filename. The filename will be prepended with the config directory.
func UnmarshalFromFile ¶
UnmarshalFromFile unmarshals the given filename to the given interface. The filename will be prepended with the config directory. IsNotExist errors are ignored.
Types ¶
type Entry ¶
type Entry struct { Name string Value EntryValue }
type EntryValue ¶
EntryValue with JSON serde capabilities.
func InputEntry ¶
func InputEntry(value *string, change func(string) error) EntryValue
func Switch ¶
func Switch(value *bool, change func(bool)) EntryValue
type SectionEntries ¶
type SectionEntries map[string]EntryValue
func (SectionEntries) UnmarshalJSON ¶
func (s SectionEntries) UnmarshalJSON(b []byte) error
UnmarshalJSON ignores all JSON entries with unknown keys.