summaryrefslogtreecommitdiff
path: root/config.Panic.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.Panic.go')
-rw-r--r--config.Panic.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/config.Panic.go b/config.Panic.go
new file mode 100644
index 0000000..45d233e
--- /dev/null
+++ b/config.Panic.go
@@ -0,0 +1,37 @@
+package config
+
+import "google.golang.org/protobuf/proto"
+
+func GetPanic(flag string) string {
+ saveMu.Lock()
+ defer saveMu.Unlock()
+ if configPB == nil {
+ configPanic(flag)
+ }
+ found := configPB.FindByKey(flag)
+ if found == nil {
+ configPanic(flag)
+ }
+ return found.Value
+}
+
+func configPanic(varname string) {
+ saveMu.Lock()
+ defer saveMu.Unlock()
+ if configPB == nil {
+ panic("config file is nil")
+ }
+ panic("config name '" + varname + "' not found")
+}
+
+// should this be a function?
+func LoadPanicPB(pb proto.Message) error {
+ fullname, err := GetFilename(pb)
+ if err != nil {
+ panic("config.LoadPB() err")
+ }
+ if fullname == "" {
+ panic("config.LoadPB() got blank filename = ''")
+ }
+ return LoadPB(pb)
+}