summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-17 12:57:37 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-17 12:57:37 +0200
commit182338a22fdc5b02bf0d272b98daa4e4e6253fa2 (patch)
tree68fb0baae3ed64263c7ca2dc637b1fd512291a05
downloadfeed2imap-go-182338a22fdc5b02bf0d272b98daa4e4e6253fa2.tar.gz
feed2imap-go-182338a22fdc5b02bf0d272b98daa4e4e6253fa2.tar.bz2
feed2imap-go-182338a22fdc5b02bf0d272b98daa4e4e6253fa2.zip
Initial commit
Diffstat (limited to '')
-rw-r--r--go.mod5
-rw-r--r--go.sum4
-rw-r--r--main.go54
3 files changed, 63 insertions, 0 deletions
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..590d5c2
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,5 @@
+module github.com/Necoro/feed2imap-go
+
+go 1.13
+
+require gopkg.in/yaml.v2 v2.2.8
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..74b18ac
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,4 @@
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
+gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..9f20203
--- /dev/null
+++ b/main.go
@@ -0,0 +1,54 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "log"
+
+ "gopkg.in/yaml.v2"
+)
+
+var cfg = flag.String("f", "config.yml", "configuration file")
+
+type ConfigMap map[string]interface{}
+
+type Feed struct {
+ Name string
+ Url string
+ MinFreq int `yaml:"min-frequency"`
+ ConfigMap `yaml:",inline"`
+}
+
+type Group struct {
+ Group string
+ Feeds []GroupFeed
+}
+
+type GroupFeed struct {
+ Target string
+ Feed `yaml:",inline"`
+ Group `yaml:",inline"`
+}
+
+type Yaml struct {
+ GlobalConfig ConfigMap `yaml:",inline"`
+ Feeds []GroupFeed
+}
+
+func main() {
+ log.Print("Starting up...")
+ flag.Parse()
+
+ log.Printf("Reading configuration file '%s'", *cfg)
+ buf, err := ioutil.ReadFile(*cfg)
+ if err != nil {
+ msg := fmt.Sprint("No file found: ", *cfg)
+ panic(msg)
+ }
+
+ var m Yaml
+ yaml.Unmarshal(buf, &m)
+ fmt.Printf("--- m:\n%+v\n\n", m)
+
+}