Documentation ¶
Overview ¶
For saving struct to dir, use one of the following functions: SaveToCurrentDir, SaveToUserConfigDir, SaveToSystemConfigDir, WriteConfig
For loading a config file, use one of the following functions: LoadConfig, ReadConfig
To get the various standard paths, use these functions: PathCurrentDir, PathUserConfigDir, PathSystemConfigDir
Index ¶
- func LoadConfig(appName, configFile string, v any) (configPath string, err error)
- func LoadFromCurrentDir(configFile string, v any) (configPath string, err error)
- func LoadFromSytemConfigDir(appName, configFile string, v any) (configPath string, err error)
- func LoadFromUserConfigDir(appName, configFile string, v any) (configPath string, err error)
- func PathCurrentDir(configFile string) (configPath string)
- func PathSystemConfigDir(appName, configFile string) (configPath string, err error)
- func PathUserConfigDir(appName, configFile string) (configPath string, err error)
- func ReadConfig(configPath string, v any) error
- func SaveToCurrentDir(configFile string, v any) error
- func SaveToSystemConfigDir(appName, configFile string, v any) error
- func SaveToUserConfigDir(appName, configFile string, v any) error
- func WriteConfig(configPath string, v any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadConfig ¶ added in v1.1.0
Tries to read TOML config into v (pointer to struct). Paths to check (in order): 1. Current dir, 2. User config dir, 3. System config dir. Attempts to read file with provided configFile
func LoadFromCurrentDir ¶ added in v1.1.5
Load Config from currentDir/appName
func LoadFromSytemConfigDir ¶ added in v1.1.5
Load Config from sytemConfigDir/appName
func LoadFromUserConfigDir ¶ added in v1.1.5
Load Config from userConfigDir/appName
func PathCurrentDir ¶
Return absolute path to config file in current dir with provided configFile. If current work dir cannot be determined, the configFile will be returned.
func PathSystemConfigDir ¶
Return absolute path to config file in system config dir with provided configFile, or error if it fails.
func PathUserConfigDir ¶
Return absolute path to config file in user config dir with provided configFile, or error if it fails.
func ReadConfig ¶
Read TOML file from a specific path into v.
func SaveToCurrentDir ¶ added in v1.1.1
Marshall struct to TOML and save in current dir with provided configFile
func SaveToSystemConfigDir ¶ added in v1.1.0
Marshall struct to TOML and save in 'system config' dir with provided configFile
func SaveToUserConfigDir ¶ added in v1.1.0
Marshall struct to TOML and save in 'user config' dir with provided configFile
func WriteConfig ¶
Marshall struct to TOML and write to provided path. WriteConfig attempts to create parent dirs, if they do not exist.
Types ¶
This section is empty.