aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--internal/imap/cmds.go1
-rw-r--r--internal/imap/commando.go4
-rw-r--r--internal/imap/connection.go4
-rw-r--r--internal/imap/imap.go15
-rw-r--r--main.go2
-rw-r--r--pkg/util/util.go6
6 files changed, 18 insertions, 14 deletions
diff --git a/internal/imap/cmds.go b/internal/imap/cmds.go
index 499d6c0..d978d80 100644
--- a/internal/imap/cmds.go
+++ b/internal/imap/cmds.go
@@ -12,7 +12,6 @@ func (client *Client) EnsureFolder(folder Folder) error {
return client.commander.execute(ensureCommando{folder})
}
-
type addCommando struct {
folder Folder
messages []string
diff --git a/internal/imap/commando.go b/internal/imap/commando.go
index 1cf688e..348c724 100644
--- a/internal/imap/commando.go
+++ b/internal/imap/commando.go
@@ -13,8 +13,8 @@ type command interface {
}
type execution struct {
- cmd command
- done chan<- error
+ cmd command
+ done chan<- error
}
func (commander *commander) execute(command command) error {
diff --git a/internal/imap/connection.go b/internal/imap/connection.go
index 4d209a9..5f62586 100644
--- a/internal/imap/connection.go
+++ b/internal/imap/connection.go
@@ -102,10 +102,10 @@ func (conn *connection) ensureFolder(folder Folder) error {
if conn.mailboxes.locking(folder) {
// someone else tried to create the MB -- try again, now that he's done
return conn.ensureFolder(folder)
- } else {
- defer conn.mailboxes.unlocking(folder)
}
+ defer conn.mailboxes.unlocking(folder)
+
log.Printf("Checking for folder '%s'", folder)
mbox, found, err := conn.list(folder.str)
diff --git a/internal/imap/imap.go b/internal/imap/imap.go
index 8f4c50e..f8c8632 100644
--- a/internal/imap/imap.go
+++ b/internal/imap/imap.go
@@ -11,20 +11,23 @@ import (
)
func newImapClient(url *URL, forceTls bool) (*imapClient.Client, error) {
+ var (
+ c *imapClient.Client
+ err error
+ )
+
if forceTls {
- c, err := imapClient.DialTLS(url.Host, nil)
- if err != nil {
+ if c, err = imapClient.DialTLS(url.Host, nil); err != nil {
return nil, fmt.Errorf("connecting (TLS) to %s: %w", url.Host, err)
}
log.Print("Connected to ", url.Host, " (TLS)")
- return c, nil
} else {
- c, err := imapClient.Dial(url.Host)
- if err != nil {
+ if c, err = imapClient.Dial(url.Host); err != nil {
return nil, fmt.Errorf("connecting to %s: %w", url.Host, err)
}
- return c, nil
}
+
+ return c, nil
}
func (client *Client) connect(url *URL, forceTls bool) (*connection, error) {
diff --git a/main.go b/main.go
index 5b76871..7a0749e 100644
--- a/main.go
+++ b/main.go
@@ -82,7 +82,7 @@ func run() error {
}
if success := state.Fetch(); success == 0 {
- return fmt.Errorf("No successfull feed fetch.")
+ return fmt.Errorf("No successful feed fetch.")
}
state.Filter()
diff --git a/pkg/util/util.go b/pkg/util/util.go
index 659c886..88d04c0 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -2,6 +2,7 @@ package util
import "time"
+// StrContains searches for `needle` in `haystack` and returns `true` if found.
func StrContains(haystack []string, needle string) bool {
for _, s := range haystack {
if s == needle {
@@ -12,10 +13,11 @@ func StrContains(haystack []string, needle string) bool {
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() {
return "not set"
- } else {
- return t.Format(time.ANSIC)
}
+
+ return t.Format(time.ANSIC)
}