summaryrefslogtreecommitdiff
path: root/env
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2024-09-30 11:16:28 -0400
committerGitHub <noreply@github.com>2024-09-30 11:16:28 -0400
commit18791a4e6e08de406e9c1e257cc4be2a85f29eea (patch)
tree0a32b7b821a229e0bbdf11775f3e66c2fce24217 /env
parent69d3e0c46e34a57e6cfcb58d36b28c6f0beb134e (diff)
feat(config): Allow avoiding reading default config file (#2227)
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
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)
+}