GetValueOrDefault gets the value of an environment variable. If it's empty, it will return the given default value instead.
(key, def string)
| 38 | // GetValueOrDefault gets the value of an environment variable. |
| 39 | // If it's empty, it will return the given default value instead. |
| 40 | func GetValueOrDefault(key, def string) string { |
| 41 | val := os.Getenv(key) |
| 42 | if val == "" { |
| 43 | val = def |
| 44 | } |
| 45 | |
| 46 | return val |
| 47 | } |
| 48 | |
| 49 | // MapToPairs creates a slice of environment variable "key=value" pairs from a |
| 50 | // map. |