config
config copied to clipboard
Panic on missing key/value
Hi,
is there any support for panic on missing config keys and values?
Right now I have a wrapper code that calls the config tool with direct reads to accomplish that:
// Code snippet for panic on missing key/value
func (*ConfigFileReader) MustHaveString(key string) string {
value := config.String(key)
if len(value) == 0 {
log.Panic("Config file key not found or has no value: ", key)
}
return value
}
Best Gabriele
Oh ... you suggestion add like: MustString(), MustInt() ?