Name config files ".conf"

This commit is contained in:
Brian Buller 2017-09-14 08:45:16 -05:00
parent a59425cd2e
commit f64aa66979
2 changed files with 15 additions and 15 deletions

View File

@ -25,54 +25,54 @@ func NewConfig(name string) (*Config, error) {
return c, nil
}
// GetKeyList at the config level returns all keys in the <c.name>.toml file
// GetKeyList at the config level returns all keys in the <c.name>.conf file
func (c *Config) GetKeyList() []string {
return c.generalConfig.GetKeyList()
}
// Set at the config level sets a value in the <c.name>.toml file
// Set at the config level sets a value in the <c.name>.conf file
func (c *Config) Set(k, v string) error {
return c.generalConfig.Set(k, v)
}
// SetBytes at the config level sets a value in the <c.name>.toml file
// SetBytes at the config level sets a value in the <c.name>.conf file
func (c *Config) SetBytes(k string, v []byte) error {
return c.generalConfig.SetBytes(k, v)
}
// SetInt saves an integer (as a string) in the <c.name>.toml file
// SetInt saves an integer (as a string) in the <c.name>.conf file
func (c *Config) SetInt(k string, v int) error {
return c.generalConfig.SetInt(k, v)
}
// SetDateTime saves a time.Time (as a string) in the <c.name>.toml file
// SetDateTime saves a time.Time (as a string) in the <c.name>.conf file
func (c *Config) SetDateTime(k string, v time.Time) error {
return c.generalConfig.SetDateTime(k, v)
}
// SetArray saves a string slice in the <c.name>.toml file
// SetArray saves a string slice in the <c.name>.conf file
func (c *Config) SetArray(k string, v []string) error {
return c.generalConfig.SetArray(k, v)
}
// Get at the config level retrieves a value from the <c.name>.toml file
// Get at the config level retrieves a value from the <c.name>.conf file
func (c *Config) Get(k string) string {
return c.generalConfig.Get(k)
}
// GetBytes at the config level retrieves a value from the <c.name>.toml file
// GetBytes at the config level retrieves a value from the <c.name>.conf file
// and returns it as a byte slice
func (c *Config) GetBytes(k string) []byte {
return c.generalConfig.GetBytes(k)
}
// GetInt at the config level retrieves a value from the <c.name>.toml file
// 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 (c *Config) GetInt(k string) (int, error) {
return c.generalConfig.GetInt(k)
}
// GetDateTime at the config level retrieves a value from the <c.name>.toml file
// GetDateTime at the config level retrieves a value from the <c.name>.conf file
func (c *Config) GetDateTime(k string) (time.Time, error) {
return c.generalConfig.GetDateTime(k)
}
@ -81,7 +81,7 @@ func (c *Config) GetArray(k string) ([]string, error) {
return c.generalConfig.GetArray(k)
}
// DeleteKey at the config level removes a key from the <c.name>.toml file
// DeleteKey at the config level removes a key from the <c.name>.conf file
func (c *Config) DeleteKey(k string) error {
return c.generalConfig.DeleteKey(k)
}

View File

@ -43,8 +43,8 @@ func (gf *GeneralConfig) Load() error {
return errors.New("Invalid ConfigFile Name: " + gf.Path + string(os.PathSeparator) + gf.Name)
}
// Config files end with .toml
cfgPath := gf.Path + string(os.PathSeparator) + gf.Name + ".toml"
// Config files end with .conf
cfgPath := gf.Path + string(os.PathSeparator) + gf.Name + ".conf"
tomlData, err := ioutil.ReadFile(cfgPath)
if err != nil {
// Couldn't find the file, save a new one
@ -61,7 +61,7 @@ func (gf *GeneralConfig) Load() error {
// Save writes the config to file(s)
func (gf *GeneralConfig) Save() error {
buf := new(bytes.Buffer)
cfgPath := gf.Path + string(os.PathSeparator) + gf.Name + ".toml"
cfgPath := gf.Path + string(os.PathSeparator) + gf.Name + ".conf"
if err := toml.NewEncoder(buf).Encode(gf); err != nil {
return err
}
@ -89,7 +89,7 @@ func (gf *GeneralConfig) Set(k, v string) error {
return nil
}
// SetBytes at the config level sets a value in the <c.name>.toml file
// SetBytes at the config level sets a value in the <c.name>.conf file
func (gf *GeneralConfig) SetBytes(k string, v []byte) error {
return gf.Set(k, string(v))
}