diff options
| author | Jeff Carr <[email protected]> | 2025-10-20 05:50:38 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-20 05:50:38 -0500 |
| commit | 8a24584262a90956e012cee7b03c8c2b9f4b794c (patch) | |
| tree | 8b7d0afd04e717d7c07da5eb2894debd74ec2307 /config.Panic.go | |
| parent | b6e93c08d601a7a6c27a0fdcdf98f6cb7dc9ccd8 (diff) | |
reworking this to make it more sane. hopefully.
Diffstat (limited to 'config.Panic.go')
| -rw-r--r-- | config.Panic.go | 37 |
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) +} |
