diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-04-18 00:44:04 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-04-18 00:44:04 +0200 |
commit | 1dffefe667760113d23f89e65b066a78b9d7e0b0 (patch) | |
tree | 41f7d4485f7fd98838215f99ef66dc57092bcfb1 /internal/config/yaml.go | |
parent | 5b1a3c9c54652f4ed70677729ccaeabb498f0954 (diff) | |
download | feed2imap-go-1dffefe667760113d23f89e65b066a78b9d7e0b0.tar.gz feed2imap-go-1dffefe667760113d23f89e65b066a78b9d7e0b0.tar.bz2 feed2imap-go-1dffefe667760113d23f89e65b066a78b9d7e0b0.zip |
Tests
Diffstat (limited to 'internal/config/yaml.go')
-rw-r--r-- | internal/config/yaml.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/internal/config/yaml.go b/internal/config/yaml.go index 335dede..aa58685 100644 --- a/internal/config/yaml.go +++ b/internal/config/yaml.go @@ -1,6 +1,14 @@ package config -import "fmt" +import ( + "fmt" + "gopkg.in/yaml.v3" +) + +type config struct { + GlobalConfig Map `yaml:",inline"` + Feeds []configGroupFeed +} type Group struct { Group string @@ -32,6 +40,16 @@ func (grpFeed *configGroupFeed) target() string { return grpFeed.Group.Group } +func parse(buf []byte) (config, error) { + var parsedCfg config + if err := yaml.Unmarshal(buf, &parsedCfg); err != nil { + return parsedCfg, fmt.Errorf("while unmarshalling: %w", err) + } + fmt.Printf("--- parsedCfg:\n%+v\n\n", parsedCfg) + + return parsedCfg, nil +} + func appTarget(target, app string) string { if target == "" { return app |