summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorHubert Hirtz <hubert.hirtz@laposte.net>2020-05-31 23:20:18 +0200
committerHubert Hirtz <hubert.hirtz@laposte.net>2020-06-03 15:41:51 +0200
commit881d63465cdb17357438763d4d2996d5f1d92fcd (patch)
tree36b1b7c852105d34ee2a8d71f6967b3e448ba3b7 /config.go
Initial commit
Diffstat (limited to 'config.go')
-rw-r--r--config.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/config.go b/config.go
new file mode 100644
index 0000000..8736f1d
--- /dev/null
+++ b/config.go
@@ -0,0 +1,30 @@
+package senpai
+
+import (
+ "gopkg.in/yaml.v2"
+ "io/ioutil"
+)
+
+type Config struct {
+ Addr string
+ User string
+ Password string
+}
+
+func ParseConfig(buf []byte) (cfg Config, err error) {
+ err = yaml.Unmarshal(buf, &cfg)
+ return
+}
+
+func LoadConfigFile(filename string) (cfg Config, err error) {
+ var buf []byte
+
+ buf, err = ioutil.ReadFile(filename)
+ if err != nil {
+ return
+ }
+
+ cfg, err = ParseConfig(buf)
+
+ return
+}