summaryrefslogtreecommitdiff
path: root/confhelper
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2013-09-14 22:37:06 +0200
committerKevin Chabowski <kevin@kch42.de>2013-09-14 22:37:06 +0200
commitc0a06609919d09fbcb6326ff69cc455dd13506ef (patch)
tree7a56a337f9ac3b9b3fc099ea846fd884112469b7 /confhelper
parent33c32f1e026482d60de635656a53de723114fcb7 (diff)
downloadmailremind-c0a06609919d09fbcb6326ff69cc455dd13506ef.tar.gz
mailremind-c0a06609919d09fbcb6326ff69cc455dd13506ef.tar.bz2
mailremind-c0a06609919d09fbcb6326ff69cc455dd13506ef.zip
Reduced duplicate code for config reading.
Diffstat (limited to 'confhelper')
-rw-r--r--confhelper/confhelper.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/confhelper/confhelper.go b/confhelper/confhelper.go
new file mode 100644
index 0000000..607f50f
--- /dev/null
+++ b/confhelper/confhelper.go
@@ -0,0 +1,22 @@
+package confhelper
+
+import (
+ "github.com/kch42/simpleconf"
+ "log"
+)
+
+func ConfStringOrFatal(conf simpleconf.Config, section, key string) string {
+ s, err := conf.GetString(section, key)
+ if err != nil {
+ log.Fatalf("Could not read config value %s.%s: %s", section, key, err)
+ }
+ return s
+}
+
+func ConfIntOrFatal(conf simpleconf.Config, section, key string) int64 {
+ i, err := conf.GetInt(section, key)
+ if err != nil {
+ log.Fatalf("Could not read config value %s.%s: %s", section, key, err)
+ }
+ return i
+}