diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2017-04-28 23:33:19 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2017-04-28 23:33:19 -0400 |
| commit | 9c4dfaec4fdfc0f4265567f44fa67d7f1dbf451a (patch) | |
| tree | bf9480c4fc1fec786b9020dab0d5e005c1a2136f | |
| parent | 5a556eb62b59c5359ac514534b05b5144415535a (diff) | |
Mild Getenv refactor
Go from two `os.Getenv` calls to one `os.LookupEnv` call.
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
| -rw-r--r-- | env.go | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -10,10 +10,10 @@ type Env struct { // It returns the value, or the default (or an emptry string) if the variable is // not set. func (e *Env) Getenv(key string, def ...string) string { - val := os.Getenv(key) - if val == "" && len(def) > 0 { + val, ok := os.LookupEnv(key) + if !ok && len(def) > 0 { return def[0] } - return os.Getenv(key) + return val } |
