From 17001a1537e98d40a9c4552344727c288da4c9e0 Mon Sep 17 00:00:00 2001 From: balki <3070606-balki@users.noreply.gitlab.com> Date: Fri, 27 May 2022 23:05:59 -0400 Subject: [PATCH] filter removes duplicates --- app/config.go | 2 +- app/db.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/config.go b/app/config.go index fb68032..abdf5d8 100644 --- a/app/config.go +++ b/app/config.go @@ -110,11 +110,11 @@ func ParseConfig(configPath string) (*Config, error) { } func (fu *FeedURL) UnmarshalYAML(node *yaml.Node) error { - *fu = []string{""} switch node.Kind { case yaml.SequenceNode: return node.Decode((*[]string)(fu)) case yaml.ScalarNode: + *fu = []string{""} return node.Decode(&(*fu)[0]) } return fmt.Errorf("unexpected node type: %s, at %d:%d", node.ShortTag(), node.Line, node.Column) diff --git a/app/db.go b/app/db.go index faf7b1e..59cb371 100644 --- a/app/db.go +++ b/app/db.go @@ -78,6 +78,7 @@ func (d *db) Filter(entries []parser.FeedEntry) ([]parser.FeedEntry, error) { for _, entry := range entries { if _, ok := d.seenLinks[entry.Link]; !ok { filteredEntries = append(filteredEntries, entry) + d.seenLinks[entry.Link] = struct{}{} } } return filteredEntries, nil