Documentation ¶
Overview ¶
Package userConfig eases the use of config files in a user's home directory
Package userConfig eases the use of config files in a user's home directory
Index ¶
- type AddonConfig
- func (af *AddonConfig) Get(category, k string) string
- func (af *AddonConfig) GetFullPath() string
- func (af *AddonConfig) GetName() string
- func (af *AddonConfig) GetPath() string
- func (af *AddonConfig) Load() error
- func (af *AddonConfig) Save() error
- func (af *AddonConfig) Set(category, k, v string) error
- type Config
- func (c *Config) DeleteKey(k string) error
- func (c *Config) Get(k string) string
- func (c *Config) GetArray(k string) ([]string, error)
- func (c *Config) GetBytes(k string) []byte
- func (c *Config) GetConfigPath() string
- func (c *Config) GetDateTime(k string) (time.Time, error)
- func (c *Config) GetInt(k string) (int, error)
- func (c *Config) GetKeyList() []string
- func (c *Config) Load() error
- func (c *Config) Save() error
- func (c *Config) Set(k, v string) error
- func (c *Config) SetArray(k string, v []string) error
- func (c *Config) SetBytes(k string, v []byte) error
- func (c *Config) SetDateTime(k string, v time.Time) error
- func (c *Config) SetInt(k string, v int) error
- type GeneralConfig
- func (gf *GeneralConfig) DeleteKey(k string) error
- func (gf *GeneralConfig) Get(k string) string
- func (gf *GeneralConfig) GetArray(k string) ([]string, error)
- func (gf *GeneralConfig) GetBytes(k string) []byte
- func (gf *GeneralConfig) GetDateTime(k string) (time.Time, error)
- func (gf *GeneralConfig) GetInt(k string) (int, error)
- func (gf *GeneralConfig) GetKeyList() []string
- func (gf *GeneralConfig) Load() error
- func (gf *GeneralConfig) Save() error
- func (gf *GeneralConfig) Set(k, v string) error
- func (gf *GeneralConfig) SetArray(k string, v []string) error
- func (gf *GeneralConfig) SetBytes(k string, v []byte) error
- func (gf *GeneralConfig) SetDateTime(k string, v time.Time) error
- func (gf *GeneralConfig) SetInt(k string, v int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddonConfig ¶
type AddonConfig struct { Name string `toml:"-"` Path string `toml:"-"` Values map[string]map[string]string `toml:"-"` }
AddonConfig is an additional ConfigFile
func NewAddonConfig ¶
func NewAddonConfig(name, path string) (*AddonConfig, error)
NewAddonConfig generates a Additional Config struct
func (*AddonConfig) Get ¶
func (af *AddonConfig) Get(category, k string) string
Get gets a key/value pair from af
func (*AddonConfig) GetFullPath ¶
func (af *AddonConfig) GetFullPath() string
GetFullPath returns the full path & filename to the config file
func (*AddonConfig) GetName ¶
func (af *AddonConfig) GetName() string
GetName returns the name of this config file
func (*AddonConfig) GetPath ¶
func (af *AddonConfig) GetPath() string
GetPath returns the path of this config file
func (*AddonConfig) Load ¶
func (af *AddonConfig) Load() error
Load loads config files into the config
func (*AddonConfig) Set ¶
func (af *AddonConfig) Set(category, k, v string) error
Set sets a key/value pair in af, if unable to save, revert to old value (and return the error)
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a stuct for managing the config
func (*Config) GetBytes ¶
GetBytes at the config level retrieves a value from the <c.name>.conf file and returns it as a byte slice
func (*Config) GetConfigPath ¶
GetConfigPath just returns the config path
func (*Config) GetDateTime ¶
GetDateTime at the config level retrieves a value from the <c.name>.conf file
func (*Config) GetInt ¶
GetInt at the config level retrieves a value from the <c.name>.conf file and returns it as an integer (or an error if conversion fails)
func (*Config) GetKeyList ¶
GetKeyList at the config level returns all keys in the <c.name>.conf file
func (*Config) SetDateTime ¶
SetDateTime saves a time.Time (as a string) in the <c.name>.conf file
type GeneralConfig ¶
type GeneralConfig struct { Name string `toml:"-"` Path string `toml:"-"` ConfigFiles []string `toml:"additional_config"` RawFiles []string `toml:"raw_files"` Values map[string]string `toml:"general"` }
GeneralConfig is the basic config structure All configs make with package userConfig will have this file
func NewGeneralConfig ¶
func NewGeneralConfig(name, path string) (*GeneralConfig, error)
NewGeneralConfig generates a General Config struct
func (*GeneralConfig) DeleteKey ¶
func (gf *GeneralConfig) DeleteKey(k string) error
DeleteKey removes a key from the file
func (*GeneralConfig) Get ¶
func (gf *GeneralConfig) Get(k string) string
Get gets a key/value pair from gf
func (*GeneralConfig) GetBytes ¶
func (gf *GeneralConfig) GetBytes(k string) []byte
GetBytes gets a key/value pair from gf and returns it as a byte slice Or an error if it fails for whatever reason
func (*GeneralConfig) GetDateTime ¶
func (gf *GeneralConfig) GetDateTime(k string) (time.Time, error)
GetDateTime gets a key/value pair from gf and returns it as a time.Time An error if it can't be converted
func (*GeneralConfig) GetInt ¶
func (gf *GeneralConfig) GetInt(k string) (int, error)
GetInt gets a key/value pair from gf and return it as an integer An error if it can't be converted
func (*GeneralConfig) GetKeyList ¶
func (gf *GeneralConfig) GetKeyList() []string
GetKeyList returns a list of all keys in the config file
func (*GeneralConfig) Load ¶
func (gf *GeneralConfig) Load() error
Load loads config files into the config
func (*GeneralConfig) Save ¶
func (gf *GeneralConfig) Save() error
Save writes the config to file(s)
func (*GeneralConfig) Set ¶
func (gf *GeneralConfig) Set(k, v string) error
Set sets a key/value pair in gf, if unable to save, revert to old value (and return the error)
func (*GeneralConfig) SetArray ¶
func (gf *GeneralConfig) SetArray(k string, v []string) error
SetArray sets a string slice value (as a string) in the config file
func (*GeneralConfig) SetBytes ¶
func (gf *GeneralConfig) SetBytes(k string, v []byte) error
SetBytes at the config level sets a value in the <c.name>.conf file
func (*GeneralConfig) SetDateTime ¶
func (gf *GeneralConfig) SetDateTime(k string, v time.Time) error
SetDateTime sets a DateTime value (as a string) in the config file