~migadu/alps-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH v2] plugins/base/imap: use slices package

Silvan Jegen <s.jegen@gmail.com>
Details
Message ID
<20241209204536.22882-1-s.jegen@gmail.com>
DKIM signature
pass
Download raw message
Patch: +10 -14
This saves a few lines of code.

Note that the minimal golang version has to be updated since the slices
package has only been available since version 1.21.

Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
---
 go.mod               |  2 +-
 plugins/base/imap.go | 22 +++++++++-------------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/go.mod b/go.mod
index 3a8c975..11cf4a1 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module git.sr.ht/~migadu/alps

go 1.18
go 1.21

require (
	github.com/aymerick/douceur v0.2.0
diff --git a/plugins/base/imap.go b/plugins/base/imap.go
index ec4947d..55ea5cb 100644
--- a/plugins/base/imap.go
+++ b/plugins/base/imap.go
@@ -6,10 +6,9 @@ import (
	"fmt"
	"io"
	"net/url"
	"sort"
	"slices"
	"strconv"
	"strings"
	//"time"

	"github.com/dustin/go-humanize"
	"github.com/emersion/go-imap/v2"
@@ -73,14 +72,15 @@ func listMailboxes(conn *imapclient.Client) ([]MailboxInfo, error) {
		return nil, fmt.Errorf("failed to list mailboxes: %v", err)
	}

	sort.Slice(mailboxes, func(i, j int) bool {
		if mailboxes[i].Mailbox == "INBOX" {
			return true
	slices.SortFunc(mailboxes, func(i, j MailboxInfo) int {
		if i.Mailbox == "INBOX" {
			return 1
		}
		if mailboxes[j].Mailbox == "INBOX" {
			return false
		if j.Mailbox == "INBOX" {
			return -1
		}
		return mailboxes[i].Mailbox < mailboxes[j].Mailbox

		return strings.Compare(i.Mailbox, j.Mailbox)
	})
	return mailboxes, nil
}
@@ -465,11 +465,7 @@ func listMessages(conn *imapclient.Client, mboxName string, page, messagesPerPag
		msgs = append(msgs, IMAPMessage{msg, mboxName})
	}

	// Reverse list of messages
	for i := len(msgs)/2 - 1; i >= 0; i-- {
		opp := len(msgs) - 1 - i
		msgs[i], msgs[opp] = msgs[opp], msgs[i]
	}
	slices.Reverse(msgs)

	return msgs, total, nil
}
-- 
2.47.1
Details
Message ID
<6g-6Tl1jLkA0XxL3Jm8xwww3WF4q2cWXxkg1-A27oKUdM1UzuphT7SW4Zcqbciid1ycYFT4Yt2gmj8biBxjWh5iSllm2JXsWNou6dUbiMfY=@emersion.fr>
In-Reply-To
<20241209204536.22882-1-s.jegen@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Sorry, I think I prefer to keep building under older Go versions, rather
than bump the minimum requirement just for some convenience utilities.
Silvan Jegen <s.jegen@gmail.com>
Details
Message ID
<249C5R2GK23EA.1YTGKBRNJI5G4@homearch.localdomain>
In-Reply-To
<6g-6Tl1jLkA0XxL3Jm8xwww3WF4q2cWXxkg1-A27oKUdM1UzuphT7SW4Zcqbciid1ycYFT4Yt2gmj8biBxjWh5iSllm2JXsWNou6dUbiMfY=@emersion.fr> (view parent)
DKIM signature
pass
Download raw message
Simon Ser <contact@emersion.fr> wrote:
> Sorry, I think I prefer to keep building under older Go versions, rather
> than bump the minimum requirement just for some convenience utilities.

Go version 1.18 is not supported anymore and given the backwards
compatibility promise of Go v1, there is very little reason to avoid
upgrading.

I do see where your coming from though and it's your call to make! :)

Then let's reject this patch set.

Cheers,
Silvan
Reply to thread Export thread (mbox)