diff options
author | Simon Ser <contact@emersion.fr> | 2019-12-03 11:12:26 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2019-12-03 11:12:26 +0100 |
commit | 4cbe2fde9dad377dfedbf57b5e77df78e4e5b417 (patch) | |
tree | f01a9e0575fc328654776a97f18761056c1e93e7 | |
parent | 61f2f3e139dbc39618a9764a5b80af61933167da (diff) | |
download | alps-4cbe2fde9dad377dfedbf57b5e77df78e4e5b417.tar.gz alps-4cbe2fde9dad377dfedbf57b5e77df78e4e5b417.zip |
go fmt
-rw-r--r-- | conn_pool.go | 2 | ||||
-rw-r--r-- | imap.go | 8 | ||||
-rw-r--r-- | server.go | 18 |
3 files changed, 14 insertions, 14 deletions
diff --git a/conn_pool.go b/conn_pool.go index ad6b736..fb530b9 100644 --- a/conn_pool.go +++ b/conn_pool.go @@ -23,7 +23,7 @@ var ErrSessionExpired = errors.New("session expired") // TODO: expiration timer type ConnPool struct { locker sync.Mutex - conns map[string]*imapclient.Client + conns map[string]*imapclient.Client } func NewConnPool() *ConnPool { @@ -9,9 +9,9 @@ import ( "strings" "github.com/emersion/go-imap" + 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" ) func (s *Server) connectIMAP() (*imapclient.Client, error) { @@ -41,7 +41,7 @@ func (s *Server) connectIMAP() (*imapclient.Client, error) { func listMailboxes(conn *imapclient.Client) ([]*imap.MailboxInfo, error) { ch := make(chan *imap.MailboxInfo, 10) done := make(chan error, 1) - go func () { + go func() { done <- conn.List("", "*", ch) }() @@ -171,8 +171,8 @@ func listMessages(conn *imapclient.Client, mboxName string) ([]imapMessage, erro } // Reverse list of messages - for i := len(msgs)/2-1; i >= 0; i-- { - opp := len(msgs)-1-i + for i := len(msgs)/2 - 1; i >= 0; i-- { + opp := len(msgs) - 1 - i msgs[i], msgs[opp] = msgs[opp], msgs[i] } @@ -8,16 +8,16 @@ import ( "strings" "time" - "github.com/labstack/echo/v4" imapclient "github.com/emersion/go-imap/client" + "github.com/labstack/echo/v4" ) const cookieName = "koushin_session" type Server struct { imap struct { - host string - tls bool + host string + tls bool insecure bool pool *ConnPool @@ -51,15 +51,15 @@ func NewServer(imapURL string) (*Server, error) { type context struct { echo.Context server *Server - conn *imapclient.Client + conn *imapclient.Client } var aLongTimeAgo = time.Unix(233431200, 0) func (c *context) setToken(token string) { cookie := http.Cookie{ - Name: cookieName, - Value: token, + Name: cookieName, + Value: token, HttpOnly: true, // TODO: domain, secure } @@ -179,9 +179,9 @@ func New(imapURL string) *echo.Echo { } return ctx.Render(http.StatusOK, "mailbox.html", map[string]interface{}{ - "Mailbox": ctx.conn.Mailbox(), + "Mailbox": ctx.conn.Mailbox(), "Mailboxes": mailboxes, - "Messages": msgs, + "Messages": msgs, }) }) @@ -206,7 +206,7 @@ func New(imapURL string) *echo.Echo { return ctx.Render(http.StatusOK, "message.html", map[string]interface{}{ "Mailbox": ctx.conn.Mailbox(), "Message": msg, - "Body": body, + "Body": body, }) }) |