Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/gluon_bench/benchmark/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"fmt"
"os"
"path/filepath"
"slices"

"github.com/ProtonMail/gluon/benchmarks/gluon_bench/flags"
"github.com/ProtonMail/gluon/benchmarks/gluon_bench/reporter"
"golang.org/x/exp/slices"
)

func RunMain() {
Expand Down
4 changes: 2 additions & 2 deletions connector/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import (
"context"
"errors"
"fmt"
"slices"
"sync"
"sync/atomic"
"time"

"github.com/ProtonMail/gluon/constants"
"github.com/ProtonMail/gluon/imap"
"github.com/ProtonMail/gluon/internal/ticker"
"github.com/ProtonMail/gluon/internal/utils"
"github.com/ProtonMail/gluon/pkg/utils"
"github.com/sirupsen/logrus"
"golang.org/x/exp/slices"
)

var (
Expand Down
10 changes: 5 additions & 5 deletions connector/dummy_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"time"

"github.com/ProtonMail/gluon/imap"
"github.com/ProtonMail/gluon/pkg/utils"
"github.com/bradenaw/juniper/xslices"
"github.com/google/uuid"
"golang.org/x/exp/maps"
)

type dummyState struct {
Expand Down Expand Up @@ -61,7 +61,7 @@ func (state *dummyState) getMailboxes() []imap.Mailbox {
state.lock.Lock()
defer state.lock.Unlock()

return xslices.Map(maps.Keys(state.mailboxes), func(mboxID imap.MailboxID) imap.Mailbox {
return xslices.Map(utils.Keys(state.mailboxes), func(mboxID imap.MailboxID) imap.Mailbox {
return state.toMailbox(mboxID)
})
}
Expand Down Expand Up @@ -132,7 +132,7 @@ func (state *dummyState) getMessages() []imap.Message {
state.lock.Lock()
defer state.lock.Unlock()

return xslices.Map(maps.Keys(state.messages), func(messageID imap.MessageID) imap.Message {
return xslices.Map(utils.Keys(state.messages), func(messageID imap.MessageID) imap.Message {
return state.toMessage(messageID)
})
}
Expand All @@ -149,7 +149,7 @@ func (state *dummyState) getMessageCreatedUpdate(id imap.MessageID) (*imap.Messa
return &imap.MessageCreated{
Message: state.toMessage(id),
Literal: msg.literal,
MailboxIDs: maps.Keys(msg.mboxIDs),
MailboxIDs: utils.Keys(msg.mboxIDs),
ParsedMessage: msg.parsed,
}, nil
}
Expand All @@ -170,7 +170,7 @@ func (state *dummyState) getMailboxIDs(messageID imap.MessageID) []imap.MailboxI
state.lock.Lock()
defer state.lock.Unlock()

return maps.Keys(state.messages[messageID].mboxIDs)
return utils.Keys(state.messages[messageID].mboxIDs)
}

// nolint: unused
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ require (
github.com/sirupsen/logrus v1.9.4
github.com/stretchr/testify v1.11.1
go.uber.org/goleak v1.3.0
golang.org/x/exp v0.0.0-20260312153236-7ab1446f8b90
golang.org/x/sys v0.43.0
golang.org/x/text v0.36.0
gopkg.in/yaml.v3 v3.0.1
Expand All @@ -31,6 +30,7 @@ require (
github.com/kr/pretty v0.3.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
golang.org/x/exp v0.0.0-20260312153236-7ab1446f8b90 // indirect
golang.org/x/sync v0.20.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
16 changes: 8 additions & 8 deletions imap/flags.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package imap

import (
"slices"
"strings"

"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"github.com/ProtonMail/gluon/pkg/utils"
)

const (
Expand Down Expand Up @@ -70,7 +70,7 @@ func (fs FlagSet) Len() int {
// ToSlice Returns the list of flags in the set as a sorted string slice. The returned list is a hard copy of the internal
// slice to avoid direct modifications of the FlagSet value that would break the uniqueness and case insensitivity rules.
func (fs FlagSet) ToSlice() []string {
flags := maps.Values(fs)
flags := utils.Values(fs)

slices.Sort(flags)

Expand All @@ -79,7 +79,7 @@ func (fs FlagSet) ToSlice() []string {

// ToSliceUnsorted is the same as ToSlice, but does not sort the returned value.
func (fs FlagSet) ToSliceUnsorted() []string {
return maps.Values(fs)
return utils.Values(fs)
}

// Contains returns true if and only if the flag is in the set.
Expand Down Expand Up @@ -146,11 +146,11 @@ func (fs FlagSet) AddToSelf(flags ...string) {
}

func (fs FlagSet) AddFlagSet(set FlagSet) FlagSet {
return fs.Add(maps.Values(set)...)
return fs.Add(utils.Values(set)...)
}

func (fs FlagSet) AddFlagSetToSelf(set FlagSet) {
fs.add(maps.Values(set)...)
fs.add(utils.Values(set)...)
}

func (fs FlagSet) add(flags ...string) {
Expand Down Expand Up @@ -191,15 +191,15 @@ func (fs FlagSet) Remove(flags ...string) FlagSet {
}

func (fs FlagSet) RemoveFlagSet(set FlagSet) FlagSet {
return fs.Remove(maps.Values(set)...)
return fs.Remove(utils.Values(set)...)
}

func (fs FlagSet) RemoveFromSelf(flags ...string) {
fs.remove(flags...)
}

func (fs FlagSet) RemoveFlagSetFromSelf(set FlagSet) {
fs.Remove(maps.Values(set)...)
fs.Remove(utils.Values(set)...)
}

func (fs FlagSet) remove(flags ...string) {
Expand Down
6 changes: 3 additions & 3 deletions imap/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package imap

import (
"net/mail"
"slices"
"strconv"
"strings"

"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"github.com/ProtonMail/gluon/pkg/utils"
)

type parListWriter interface {
Expand Down Expand Up @@ -114,7 +114,7 @@ func (c *paramList) addNumber(writer parListWriter, v int) *paramList {
func (c *paramList) addMap(writer parListWriter, v map[string]string) *paramList {
c.onWrite(writer)

keys := maps.Keys(v)
keys := utils.Keys(v)

slices.Sort(keys)

Expand Down
2 changes: 1 addition & 1 deletion imap/seqset.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package imap

import (
"fmt"
"slices"
"strconv"
"strings"

"github.com/bradenaw/juniper/xslices"
"golang.org/x/exp/slices"
)

type SeqVal struct {
Expand Down
2 changes: 1 addition & 1 deletion imap/uid_validity_generator_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package imap

import (
"slices"
"testing"
"time"

"github.com/bradenaw/juniper/parallel"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
)

func TestEpochUIDValidityGenerator_Generate(t *testing.T) {
Expand Down
8 changes: 5 additions & 3 deletions internal/backend/connector_updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import (
"io"
"os"
"runtime"
"slices"
"strings"

"github.com/ProtonMail/gluon/db"
"github.com/ProtonMail/gluon/imap"
"github.com/ProtonMail/gluon/internal/ids"
"github.com/ProtonMail/gluon/internal/state"
"github.com/ProtonMail/gluon/internal/utils"
"github.com/ProtonMail/gluon/pkg/utils"
"github.com/ProtonMail/gluon/rfc822"
"github.com/bradenaw/juniper/parallel"
"github.com/bradenaw/juniper/xslices"
"github.com/sirupsen/logrus"
"golang.org/x/exp/slices"
)

// apply an incoming update originating from the connector.
Expand Down Expand Up @@ -344,7 +344,9 @@ func (user *user) applyMessagesCreated(ctx context.Context, update *imap.Message
messageForMBox[v] = messageList
}

if !slices.ContainsFunc(messageList, func(id db.MessageIDPair) bool { return id.InternalID == internalID }) {
if !slices.ContainsFunc(messageList, func(id db.MessageIDPair) bool {
return id.InternalID == internalID
}) {
messageList = append(messageList, db.MessageIDPair{InternalID: internalID, RemoteID: message.Message.ID})
messageForMBox[v] = messageList
}
Expand Down
8 changes: 4 additions & 4 deletions internal/backend/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import (
"github.com/ProtonMail/gluon/logging"
"github.com/ProtonMail/gluon/observability"
"github.com/ProtonMail/gluon/observability/metrics"
pkgutils "github.com/ProtonMail/gluon/pkg/utils"
"github.com/ProtonMail/gluon/reporter"
"github.com/ProtonMail/gluon/store"
"github.com/bradenaw/juniper/xslices"
"github.com/sirupsen/logrus"
"golang.org/x/exp/maps"
)

type user struct {
Expand Down Expand Up @@ -298,8 +298,8 @@ func (user *user) removeState(ctx context.Context, st *state.State) error {
return nil, fmt.Errorf("no such state")
}

messageIDs = utils.Filter(messageIDs, func(messageID imap.InternalMessageID) bool {
return xslices.CountFunc(maps.Values(user.states), func(other *state.State) bool {
messageIDs = pkgutils.Filter(messageIDs, func(messageID imap.InternalMessageID) bool {
return xslices.CountFunc(pkgutils.Values(user.states), func(other *state.State) bool {
return st != other && other.HasMessage(messageID)
}) == 0
})
Expand Down Expand Up @@ -372,7 +372,7 @@ func (user *user) cleanupStaleStoreData(ctx context.Context) error {
return err
}

idsToDelete := utils.Filter(storeIds, func(id imap.InternalMessageID) bool {
idsToDelete := pkgutils.Filter(storeIds, func(id imap.InternalMessageID) bool {
_, ok := dbIdMap[id]

return !ok
Expand Down
2 changes: 1 addition & 1 deletion internal/db_impl/sqlite3/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"fmt"
"slices"
"strings"
"testing"
"time"
Expand All @@ -15,7 +16,6 @@ import (
"github.com/bradenaw/juniper/xslices"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"
)

func TestMigration_VersionTooHigh(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/response/capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package response

import (
"fmt"
"slices"

"github.com/ProtonMail/gluon/imap"
"golang.org/x/exp/slices"
)

type capability struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/response/item_capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package response

import (
"fmt"
"slices"

"github.com/ProtonMail/gluon/imap"
"golang.org/x/exp/slices"
)

type itemCapability struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/response/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package response
import (
"strconv"

"golang.org/x/exp/slices"
"slices"
)

type search struct {
Expand Down
3 changes: 2 additions & 1 deletion internal/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"sync"
"time"

"slices"

"github.com/ProtonMail/gluon/async"
"github.com/ProtonMail/gluon/events"
"github.com/ProtonMail/gluon/imap"
Expand All @@ -29,7 +31,6 @@ import (
"github.com/ProtonMail/gluon/version"
"github.com/emersion/go-imap/utf7"
"github.com/sirupsen/logrus"
"golang.org/x/exp/slices"
)

const maxSessionError = 20
Expand Down
Loading
Loading