aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--internal/feed/item.go4
-rw-r--r--internal/imap/connection.go4
-rw-r--r--pkg/config/body.go5
-rw-r--r--pkg/config/config.go6
-rw-r--r--pkg/util/util.go11
5 files changed, 9 insertions, 21 deletions
diff --git a/internal/feed/item.go b/internal/feed/item.go
index 79a971c..bc1865a 100644
--- a/internal/feed/item.go
+++ b/internal/feed/item.go
@@ -4,6 +4,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
+ "slices"
"strings"
"time"
@@ -11,7 +12,6 @@ import (
"github.com/google/uuid"
"github.com/Necoro/feed2imap-go/pkg/config"
- "github.com/Necoro/feed2imap-go/pkg/util"
)
type feedImage struct {
@@ -65,7 +65,7 @@ func (item *Item) FeedLink() string {
}
func (item *Item) AddReason(reason string) {
- if !util.Contains(item.reasons, reason) {
+ if !slices.Contains(item.reasons, reason) {
item.reasons = append(item.reasons, reason)
}
}
diff --git a/internal/imap/connection.go b/internal/imap/connection.go
index 8c0f59c..201ca7d 100644
--- a/internal/imap/connection.go
+++ b/internal/imap/connection.go
@@ -3,6 +3,7 @@ package imap
import (
"errors"
"fmt"
+ "slices"
"strings"
"time"
@@ -11,7 +12,6 @@ import (
imapClient "github.com/emersion/go-imap/client"
"github.com/Necoro/feed2imap-go/pkg/log"
- "github.com/Necoro/feed2imap-go/pkg/util"
)
type client struct {
@@ -125,7 +125,7 @@ func (conn *connection) ensureFolder(folder Folder) error {
}
switch {
- case found == 0 || (found == 1 && util.Contains(mbox.Attributes, imap.NoSelectAttr)):
+ case found == 0 || (found == 1 && slices.Contains(mbox.Attributes, imap.NoSelectAttr)):
return conn.createFolder(folder.str)
case found == 1:
conn.mailboxes.add(mbox)
diff --git a/pkg/config/body.go b/pkg/config/body.go
index 17cf924..68c06da 100644
--- a/pkg/config/body.go
+++ b/pkg/config/body.go
@@ -2,10 +2,9 @@ package config
import (
"fmt"
+ "slices"
"gopkg.in/yaml.v3"
-
- "github.com/Necoro/feed2imap-go/pkg/util"
)
type Body string
@@ -22,7 +21,7 @@ func (b *Body) UnmarshalYAML(node *yaml.Node) error {
val = "default"
}
- if !util.Contains(validBody, val) {
+ if !slices.Contains(validBody, val) {
return TypeError("line %d: Invalid value for 'body': %q", node.Line, val)
}
diff --git a/pkg/config/config.go b/pkg/config/config.go
index aaf6701..db320c9 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -5,10 +5,10 @@ import (
"os"
"os/user"
"runtime"
+ "slices"
"strings"
"github.com/Necoro/feed2imap-go/pkg/log"
- "github.com/Necoro/feed2imap-go/pkg/util"
)
// Map is a convenience type for the non-mapped configuration options
@@ -114,12 +114,12 @@ func (cfg *Config) Validate() error {
// WithPartText marks whether 'text' part should be included in mails
func (opt GlobalOptions) WithPartText() bool {
- return util.Contains(opt.Parts, "text")
+ return slices.Contains(opt.Parts, "text")
}
// WithPartHtml marks whether 'html' part should be included in mails
func (opt GlobalOptions) WithPartHtml() bool {
- return util.Contains(opt.Parts, "html")
+ return slices.Contains(opt.Parts, "html")
}
// Load configuration from file and validate it
diff --git a/pkg/util/util.go b/pkg/util/util.go
index cbc6014..c0b5a17 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -2,17 +2,6 @@ package util
import "time"
-// Contains searches for `needle` in `haystack` and returns `true` if found.
-func Contains[T comparable](haystack []T, needle T) bool {
- for _, s := range haystack {
- if s == needle {
- return true
- }
- }
-
- return false
-}
-
// TimeFormat formats the given time, where an empty time is formatted as "not set".
func TimeFormat(t time.Time) string {
if t.IsZero() {