mirror of
https://github.com/kemko/nomad.git
synced 2026-01-08 03:15:42 +03:00
Added ReadDefault for supreme laziness
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user