summary refs log tree commit diff stats
path: root/cmd/cetus/env.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/cetus/env.go')
-rw-r--r--cmd/cetus/env.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/cmd/cetus/env.go b/cmd/cetus/env.go
new file mode 100644
index 0000000..9288c35
--- /dev/null
+++ b/cmd/cetus/env.go
@@ -0,0 +1,18 @@
+package main
+
+import "os"
+
+// getEnv will check if the the key exists, if it does then it'll
+// return the value otherwise it will return fallback string.
+func getEnv(key, fallback string) string {
+	// We use os.LookupEnv instead of using os.GetEnv and checking
+	// if the length equals 0 because environment variable can be
+	// set and be of length 0. User could've set key="" which
+	// means the variable was set but the length is 0. There is no
+	// reason why user would want to do this over here though.
+	value, exists := os.LookupEnv(key)
+	if !exists {
+		value = fallback
+	}
+	return value
+}
and.sh> 2020-10-15 00:42:18 +0530 Document signify, update example config' href='/andinus/leo/commit/share/leo.conf?h=v0.3.2&id=907d729ec281fa578db4993ceabc84b0aa5d6047'>907d729 ^
bc94b23 ^
1e1ab8a ^
907d729 ^

1e1ab8a ^




bc94b23 ^




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31