summaryrefslogtreecommitdiff
path: root/panic.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-21 06:40:48 -0500
committerJeff Carr <[email protected]>2025-10-21 06:40:48 -0500
commit3cf635e3c41be385b50778f7818fd50b006f1671 (patch)
treedba1a8c80e363d4f86a5f81623bc1f603e39318e /panic.go
parent4d3349c453879051a7499fa07a97dfcb20b554ea (diff)
something to act like bash ENV
Diffstat (limited to 'panic.go')
-rw-r--r--panic.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/panic.go b/panic.go
new file mode 100644
index 0000000..488cee9
--- /dev/null
+++ b/panic.go
@@ -0,0 +1,23 @@
+package ENV
+
+func GetPanic(flag string) string {
+ saveMu.Lock()
+ defer saveMu.Unlock()
+ if envPB == nil {
+ envPanic(flag)
+ }
+ found := envPB.FindByVar(flag)
+ if found == nil {
+ envPanic(flag)
+ }
+ return found.Value
+}
+
+func envPanic(varname string) {
+ saveMu.Lock()
+ defer saveMu.Unlock()
+ if envPB == nil {
+ panic("config file is nil")
+ }
+ panic("config name '" + varname + "' not found")
+}