diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-04-17 12:57:37 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-04-17 12:57:37 +0200 |
commit | 182338a22fdc5b02bf0d272b98daa4e4e6253fa2 (patch) | |
tree | 68fb0baae3ed64263c7ca2dc637b1fd512291a05 | |
download | feed2imap-go-182338a22fdc5b02bf0d272b98daa4e4e6253fa2.tar.gz feed2imap-go-182338a22fdc5b02bf0d272b98daa4e4e6253fa2.tar.bz2 feed2imap-go-182338a22fdc5b02bf0d272b98daa4e4e6253fa2.zip |
Initial commit
-rw-r--r-- | go.mod | 5 | ||||
-rw-r--r-- | go.sum | 4 | ||||
-rw-r--r-- | main.go | 54 |
3 files changed, 63 insertions, 0 deletions
@@ -0,0 +1,5 @@ +module github.com/Necoro/feed2imap-go + +go 1.13 + +require gopkg.in/yaml.v2 v2.2.8 @@ -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= @@ -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) + +} |