summaryrefslogtreecommitdiff
path: root/env
diff options
context:
space:
mode:
Diffstat (limited to 'env')
-rw-r--r--env/env.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/env/env.go b/env/env.go
index 598361bf..16e121fc 100644
--- a/env/env.go
+++ b/env/env.go
@@ -20,3 +20,13 @@ func ExpandEnv(s string) string {
fsys := datafs.WrapWdFS(osfs.NewFS())
return datafs.ExpandEnvFsys(fsys, s)
}
+
+// LookupEnv - retrieves the value of the environment variable named by the key.
+// If the variable is unset, but the same variable ending in `_FILE` is set, the
+// referenced file will be read into the value. If the key is not set, the
+// second return value will be false.
+// Otherwise the provided default (or an emptry string) is returned.
+func LookupEnv(key string) (string, bool) {
+ fsys := datafs.WrapWdFS(osfs.NewFS())
+ return datafs.LookupEnvFsys(fsys, key)
+}