Added ReadDefault for supreme laziness
This commit is contained in:
parent
1936932406
commit
ecfeba3ce6
|
@ -56,7 +56,7 @@ func NewConfig() Config {
|
|||
return config
|
||||
}
|
||||
|
||||
// GetOpt returns the specified configuration value or "".
|
||||
// Read returns the specified configuration value or "".
|
||||
func (c *Config) Read(id string) string {
|
||||
val, ok := c.Options[id]
|
||||
if !ok {
|
||||
|
@ -64,3 +64,13 @@ func (c *Config) Read(id string) string {
|
|||
}
|
||||
return val
|
||||
}
|
||||
|
||||
// ReadDefault returns the specified configuration value, or the specified
|
||||
// default value if none is set.
|
||||
func (c *Config) ReadDefault(id string, defaultValue string) string {
|
||||
val := c.Read(id)
|
||||
if val != "" {
|
||||
return val
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue