From 5d290410ee22092535533a1ba10ee7ad288342e2 Mon Sep 17 00:00:00 2001 From: Gusted Date: Wed, 4 Aug 2021 03:20:42 +0200 Subject: Use shorter if syntax --- plugins/base/routes.go | 6 ++---- session.go | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/plugins/base/routes.go b/plugins/base/routes.go index 6a733bb..321303d 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -109,12 +109,11 @@ type CategorizedMailboxes struct { } func (cc *CategorizedMailboxes) Append(mi MailboxInfo, status *MailboxStatus) { - name := mi.Name details := &MailboxDetails{ Info: &mi, Status: status, } - if name == "INBOX" { + if name := mi.Name; name == "INBOX" { cc.Common.Inbox = details } else if name == "Drafts" { cc.Common.Drafts = details @@ -194,8 +193,7 @@ func newIMAPBaseRenderData(ctx *alps.Context, mailboxes[i].Total = int(inbox.Messages) } - status, _ := subscriptions[mailboxes[i].Name] - categorized.Append(mailboxes[i], status) + categorized.Append(mailboxes[i], subscriptions[mailboxes[i].Name]) } return &IMAPBaseRenderData{ diff --git a/session.go b/session.go index 9d8921c..4bf8619 100644 --- a/session.go +++ b/session.go @@ -24,8 +24,7 @@ const maxAttachmentSize = 32 << 20 // 32 MiB func generateToken() (string, error) { b := make([]byte, 32) - _, err := rand.Read(b) - if err != nil { + if _, err := rand.Read(b); err != nil { return "", err } return base64.URLEncoding.EncodeToString(b), nil -- cgit v1.2.3