aboutsummaryrefslogtreecommitdiff
path: root/pkg/config/yaml.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-01 17:05:07 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-01 17:05:07 +0200
commitf944124325dd785085fec59210306111b3eab3b7 (patch)
tree53f88d24f42093df907f68a1a7eaf942bed0aeee /pkg/config/yaml.go
parentd7de88398ca67d7213fb849db60e5963fd3bc32f (diff)
downloadfeed2imap-go-f944124325dd785085fec59210306111b3eab3b7.tar.gz
feed2imap-go-f944124325dd785085fec59210306111b3eab3b7.tar.bz2
feed2imap-go-f944124325dd785085fec59210306111b3eab3b7.zip
Yaml: Pass `Reader` around instead of []byte
Diffstat (limited to '')
-rw-r--r--pkg/config/yaml.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/pkg/config/yaml.go b/pkg/config/yaml.go
index 93f8c10..9711130 100644
--- a/pkg/config/yaml.go
+++ b/pkg/config/yaml.go
@@ -2,6 +2,7 @@ package config
import (
"fmt"
+ "io"
"reflect"
"strings"
@@ -62,24 +63,24 @@ func (grpFeed *configGroupFeed) target() string {
return grpFeed.Group.Group
}
-func unmarshal(buf []byte, cfg *Config) (config, error) {
+func unmarshal(in io.Reader, cfg *Config) (config, error) {
parsedCfg := config{Config: cfg}
- if err := yaml.Unmarshal(buf, &parsedCfg); err != nil {
+ d := yaml.NewDecoder(in)
+ if err := d.Decode(&parsedCfg); err != nil && err != io.EOF {
return config{}, err
}
- //fmt.Printf("--- parsedCfg:\n%+v\n\n", parsedCfg)
return parsedCfg, nil
}
-func (cfg *Config) parse(buf []byte) error {
+func (cfg *Config) parse(in io.Reader) error {
var (
err error
parsedCfg config
)
- if parsedCfg, err = unmarshal(buf, cfg); err != nil {
+ if parsedCfg, err = unmarshal(in, cfg); err != nil {
return fmt.Errorf("while unmarshalling: %w", err)
}