diff options
Diffstat (limited to 'env/env.go')
| -rw-r--r-- | env/env.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/env/env.go b/env/env.go new file mode 100644 index 00000000..6966150a --- /dev/null +++ b/env/env.go @@ -0,0 +1,15 @@ +package env + +import "os" + +// Getenv retrieves the value of the environment variable named by the key. +// It returns the value, or the default (or an emptry string) if the variable is +// not set. +func Getenv(key string, def ...string) string { + val := os.Getenv(key) + if val == "" && len(def) > 0 { + return def[0] + } + + return val +} |
