From 556ce5b2c8e37c9f20afc16f030860aad04c5f9f Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 5 Jul 2021 11:19:07 +0200 Subject: [PATCH] go fmt --- plugins/base/imap.go | 4 ++-- plugins/base/routes.go | 34 +++++++++++++++++----------------- plugins/base/search.go | 2 +- server.go | 6 +++--- session.go | 8 ++++---- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/plugins/base/imap.go b/plugins/base/imap.go index 64b3164..2ca5a7e 100644 --- a/plugins/base/imap.go +++ b/plugins/base/imap.go @@ -12,10 +12,10 @@ import ( "github.com/dustin/go-humanize" "github.com/emersion/go-imap" + imapspecialuse "github.com/emersion/go-imap-specialuse" + imapclient "github.com/emersion/go-imap/client" "github.com/emersion/go-message" "github.com/emersion/go-message/textproto" - imapclient "github.com/emersion/go-imap/client" - imapspecialuse "github.com/emersion/go-imap-specialuse" ) type MailboxInfo struct { diff --git a/plugins/base/routes.go b/plugins/base/routes.go index 9b88ee5..6a733bb 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -14,13 +14,13 @@ import ( "git.sr.ht/~migadu/alps" "github.com/emersion/go-imap" + imapmove "github.com/emersion/go-imap-move" + imapclient "github.com/emersion/go-imap/client" "github.com/emersion/go-message" "github.com/emersion/go-message/mail" "github.com/emersion/go-smtp" "github.com/labstack/echo/v4" "jaytaylor.com/html2text" - imapclient "github.com/emersion/go-imap/client" - imapmove "github.com/emersion/go-imap-move" ) func registerRoutes(p *alps.GoPlugin) { @@ -85,9 +85,9 @@ type IMAPBaseRenderData struct { type MailboxRenderData struct { IMAPBaseRenderData - Messages []IMAPMessage - PrevPage, NextPage int - Query string + Messages []IMAPMessage + PrevPage, NextPage int + Query string } type MailboxDetails struct { @@ -111,7 +111,7 @@ type CategorizedMailboxes struct { func (cc *CategorizedMailboxes) Append(mi MailboxInfo, status *MailboxStatus) { name := mi.Name details := &MailboxDetails{ - Info: &mi, + Info: &mi, Status: status, } if name == "INBOX" { @@ -245,7 +245,7 @@ func handleGetMailbox(ctx *alps.Context) error { total int ) err = ctx.Session.DoIMAP(func(c *imapclient.Client) error { - var err error + var err error if query != "" { msgs, total, err = searchMessages(c, mbox.Name, query, page, messagesPerPage) } else { @@ -278,11 +278,11 @@ func handleGetMailbox(ctx *alps.Context) error { } return ctx.Render(http.StatusOK, "mailbox.html", &MailboxRenderData{ - IMAPBaseRenderData: *ibase, - Messages: msgs, - PrevPage: prevPage, - NextPage: nextPage, - Query: query, + IMAPBaseRenderData: *ibase, + Messages: msgs, + PrevPage: prevPage, + NextPage: nextPage, + Query: query, }) } @@ -303,7 +303,7 @@ func handleNewMailbox(ctx *alps.Context) error { if name == "" { return ctx.Render(http.StatusOK, "new-mailbox.html", &NewMailboxRenderData{ IMAPBaseRenderData: *ibase, - Error: "Name is required", + Error: "Name is required", }) } @@ -314,7 +314,7 @@ func handleNewMailbox(ctx *alps.Context) error { if err != nil { return ctx.Render(http.StatusOK, "new-mailbox.html", &NewMailboxRenderData{ IMAPBaseRenderData: *ibase, - Error: err.Error(), + Error: err.Error(), }) } @@ -323,7 +323,7 @@ func handleNewMailbox(ctx *alps.Context) error { return ctx.Render(http.StatusOK, "new-mailbox.html", &NewMailboxRenderData{ IMAPBaseRenderData: *ibase, - Error: "", + Error: "", }) } @@ -520,7 +520,7 @@ type composeOptions struct { // Send message, append it to the Sent mailbox, mark the original message as // answered func submitCompose(ctx *alps.Context, msg *OutgoingMessage, options *composeOptions) error { - err := ctx.Session.DoSMTP(func (c *smtp.Client) error { + err := ctx.Session.DoSMTP(func(c *smtp.Client) error { return sendMessage(c, msg) }) if err != nil { @@ -571,7 +571,7 @@ func handleCompose(ctx *alps.Context, msg *OutgoingMessage, options *composeOpti } if settings.From != "" { addr := mail.Address{ - Name: settings.From, + Name: settings.From, Address: ctx.Session.Username(), } msg.From = addr.String() diff --git a/plugins/base/search.go b/plugins/base/search.go index 4d8cef8..fd85f88 100644 --- a/plugins/base/search.go +++ b/plugins/base/search.go @@ -87,7 +87,7 @@ func splitSearchTokens(buf []byte, eof bool) (int, []byte, error) { terminator int quoted bool ) - if colon + 1 < len(buf) && buf[colon+1] == byte('"') { + if colon+1 < len(buf) && buf[colon+1] == byte('"') { terminator = bytes.IndexByte(buf[colon+2:], byte('"')) terminator += colon + 3 quoted = true diff --git a/server.go b/server.go index b1ac3a1..c4386d9 100644 --- a/server.go +++ b/server.go @@ -396,9 +396,9 @@ func New(e *echo.Echo, options *Options) (*Server, error) { } rdata := ErrorRenderData{ BaseRenderData: *NewBaseRenderData(ctx), - Err: err, - Code: code, - Status: http.StatusText(code), + Err: err, + Code: code, + Status: http.StatusText(code), } if err := ctx.Render(code, "error.html", &rdata); err != nil { diff --git a/session.go b/session.go index 8ea9634..1c7a549 100644 --- a/session.go +++ b/session.go @@ -32,7 +32,7 @@ func generateToken() (string, error) { } var ( - ErrSessionExpired = errors.New("session expired") + ErrSessionExpired = errors.New("session expired") ErrAttachmentCacheSize = errors.New("Attachments on session exceed maximum file size") ) @@ -157,13 +157,13 @@ func (s *Session) PutAttachment(in *multipart.FileHeader, for _, a := range s.attachments { size += a.File.Size } - if size + in.Size > maxAttachmentSize { + if size+in.Size > maxAttachmentSize { return "", ErrAttachmentCacheSize } s.attachments[id.String()] = &Attachment{ - File: in, - Form: form, + File: in, + Form: form, } s.attachmentsLocker.Unlock() return id.String(), nil