Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrConfigNotStructPtr = errors.New("config must be a non-nil pointer to a struct")
ErrConfigNotStructPtr is returned when config is nil or not a pointer to a struct.
var ErrIncludesVolumeName = errors.New("path includes a volume or share, file path must be relative to the user configuration directory")
ErrIncludesVolumeName is returned when fileName includes a volume name or UNC share (e.g. "C:" or "\\host\share" on Windows).
var ErrInvalidExtension = errors.New("filename does not have .yml or .yaml extension")
ErrInvalidExtension is returned when fileName does not end in ".yml" or ".yaml".
var ErrNoPath = errors.New("no filename provided")
ErrNoPath is returned when fileName is empty or contains only whitespace.
var ErrPathAbsolute = errors.New("path is absolute, file path must be relative to the user configuration directory")
ErrPathAbsolute is returned when fileName is an absolute path instead of one relative to the user configuration directory.
var ErrPathTraversal = errors.New("path tries to exit user configuration directory")
ErrPathTraversal is returned when fileName resolves to a path outside the user configuration directory.
Functions ¶
func FilePath ¶
FilePath returns the full path of the configuration file with the given filename or path. This function is called from the Save and Load functions.
func Load ¶
Load prepends the user configuration directory to the given filename, reads the configuration file, and unmarshals its data into config, which must be a pointer to a valid struct. If the file does not exist, Load creates it by calling Save with the given config (leaving config unchanged) instead of returning an error. fileName should contain the path under the user configuration directory, not the full path.
Types ¶
This section is empty.