diff options
author | Moritz Poldrack <git@moritz.sh> | 2022-07-29 21:42:02 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-08-04 21:57:52 +0200 |
commit | ef599aa8fc9faf2747d3ec9fb02fb7b80af27cc6 (patch) | |
tree | 83b3757f85dc336a8f3bef89f03b96c6970c0119 /worker | |
parent | 03f9f4c3ab633f3b567813b55b90ba9aac604e3e (diff) | |
download | aerc-ef599aa8fc9faf2747d3ec9fb02fb7b80af27cc6.tar.gz |
lint: simplify code (gosimple)
Replaces infinite for loops containing a select on a channel with a
single case with a range over the channel.
Removes redundant assignments to blank identifiers.
Remove unnecessary guard clause around delete().
Remove `if condition { return true } return false` with return condition
Signed-off-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker')
-rw-r--r-- | worker/imap/idler.go | 29 | ||||
-rw-r--r-- | worker/mbox/worker.go | 25 |
2 files changed, 24 insertions, 30 deletions
diff --git a/worker/imap/idler.go b/worker/imap/idler.go index 055bab8b..69fdc4ca 100644 --- a/worker/imap/idler.go +++ b/worker/imap/idler.go @@ -134,23 +134,20 @@ func (i *idler) waitOnIdle() { i.log("wait for idle in background") go func() { defer logging.PanicHandler() - select { - case err := <-i.done: - if err == nil { - i.log("<=(idle) waited") - i.log("connect done->") - i.worker.PostMessage(&types.Done{ - Message: types.RespondTo(&types.Connect{}), - }, nil) - } else { - i.log("<=(idle) waited; with err: %v", err) - } - i.setWaiting(false) - i.stop = make(chan struct{}) - i.log("restart") - i.Start() - return + err := <-i.done + if err == nil { + i.log("<=(idle) waited") + i.log("connect done->") + i.worker.PostMessage(&types.Done{ + Message: types.RespondTo(&types.Connect{}), + }, nil) + } else { + i.log("<=(idle) waited; with err: %v", err) } + i.setWaiting(false) + i.stop = make(chan struct{}) + i.log("restart") + i.Start() }() } diff --git a/worker/mbox/worker.go b/worker/mbox/worker.go index ab16f91e..6114870e 100644 --- a/worker/mbox/worker.go +++ b/worker/mbox/worker.go @@ -363,20 +363,17 @@ func (w *mboxWorker) handleMessage(msg types.WorkerMessage) error { } func (w *mboxWorker) Run() { - for { - select { - case msg := <-w.worker.Actions: - msg = w.worker.ProcessAction(msg) - if err := w.handleMessage(msg); err == errUnsupported { - w.worker.PostMessage(&types.Unsupported{ - Message: types.RespondTo(msg), - }, nil) - } else if err != nil { - w.worker.PostMessage(&types.Error{ - Message: types.RespondTo(msg), - Error: err, - }, nil) - } + for msg := range w.worker.Actions { + msg = w.worker.ProcessAction(msg) + if err := w.handleMessage(msg); err == errUnsupported { + w.worker.PostMessage(&types.Unsupported{ + Message: types.RespondTo(msg), + }, nil) + } else if err != nil { + w.worker.PostMessage(&types.Error{ + Message: types.RespondTo(msg), + Error: err, + }, nil) } } } |