lint: apply new formatting rules

Run `make fmt`.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Moritz Poldrack 2022-07-31 22:16:40 +02:00 committed by Robin Jarry
parent 21dcd440f8
commit aaf0a0c656
78 changed files with 288 additions and 285 deletions

View file

@ -4,9 +4,7 @@ import (
"git.sr.ht/~rjarry/aerc/commands"
)
var (
AccountCommands *commands.Commands
)
var AccountCommands *commands.Commands
func register(cmd commands.Command) {
if AccountCommands == nil {

View file

@ -9,9 +9,7 @@ import (
"git.sr.ht/~rjarry/aerc/widgets"
)
var (
history map[string]string
)
var history map[string]string
type ChangeFolder struct{}

View file

@ -9,9 +9,7 @@ import (
"github.com/mitchellh/go-homedir"
)
var (
previousDir string
)
var previousDir string
type ChangeDirectory struct{}

View file

@ -4,9 +4,7 @@ import (
"git.sr.ht/~rjarry/aerc/commands"
)
var (
ComposeCommands *commands.Commands
)
var ComposeCommands *commands.Commands
func register(cmd commands.Command) {
if ComposeCommands == nil {

View file

@ -12,8 +12,7 @@ import (
type Header struct{}
var (
headers = []string{
var headers = []string{
"From",
"To",
"Cc",
@ -22,7 +21,6 @@ var (
"Comments",
"Keywords",
}
)
func init() {
register(Header{})
@ -50,9 +48,7 @@ func (Header) Execute(aerc *widgets.Aerc, args []string) error {
return errors.New("command parsing failed")
}
var (
force bool = false
)
var force bool = false
for _, opt := range opts {
switch opt.Option {
case 'f':

View file

@ -431,7 +431,8 @@ func connectSmtps(host string) (*smtp.Client, error) {
}
func copyToSent(worker *types.Worker, dest string,
n int, msg io.Reader) <-chan error {
n int, msg io.Reader,
) <-chan error {
errCh := make(chan error)
worker.PostAction(&types.AppendMessage{
Destination: dest,

View file

@ -1,8 +1,6 @@
package commands
var (
GlobalCommands *Commands
)
var GlobalCommands *Commands
func register(cmd Command) {
if GlobalCommands == nil {

View file

@ -86,7 +86,8 @@ func (Archive) Execute(aerc *widgets.Aerc, args []string) error {
for dir, uids := range uidMap {
store.Move(uids, dir, true, func(
msg types.WorkerMessage) {
msg types.WorkerMessage,
) {
switch msg := msg.(type) {
case *types.Done:
wg.Done()
@ -111,7 +112,8 @@ func (Archive) Execute(aerc *widgets.Aerc, args []string) error {
}
func groupBy(msgs []*models.MessageInfo,
grouper func(*models.MessageInfo) string) map[string][]uint32 {
grouper func(*models.MessageInfo) string,
) map[string][]uint32 {
m := make(map[string][]uint32)
for _, msg := range msgs {
group := grouper(msg)

View file

@ -34,9 +34,7 @@ func (Copy) Execute(aerc *widgets.Aerc, args []string) error {
if err != nil {
return err
}
var (
createParents bool
)
var createParents bool
for _, opt := range opts {
switch opt.Option {
case 'p':
@ -54,8 +52,8 @@ func (Copy) Execute(aerc *widgets.Aerc, args []string) error {
}
store.Copy(uids, strings.Join(args[optind:], " "),
createParents, func(
msg types.WorkerMessage) {
msg types.WorkerMessage,
) {
switch msg := msg.(type) {
case *types.Done:
aerc.PushStatus("Messages copied.", 10*time.Second)

View file

@ -28,7 +28,6 @@ func (invite) Complete(aerc *widgets.Aerc, args []string) []string {
}
func (invite) Execute(aerc *widgets.Aerc, args []string) error {
acct := aerc.SelectedAccount()
if acct == nil {
return errors.New("no account selected")
@ -90,9 +89,7 @@ func (invite) Execute(aerc *widgets.Aerc, args []string) error {
}
}
var (
to []*mail.Address
)
var to []*mail.Address
if len(msg.Envelope.ReplyTo) != 0 {
to = msg.Envelope.ReplyTo

View file

@ -52,8 +52,8 @@ func (ModifyLabels) Execute(aerc *widgets.Aerc, args []string) error {
}
}
store.ModifyLabels(uids, add, remove, func(
msg types.WorkerMessage) {
msg types.WorkerMessage,
) {
switch msg := msg.(type) {
case *types.Done:
aerc.PushStatus("labels updated", 10*time.Second)

View file

@ -34,9 +34,7 @@ func (Move) Execute(aerc *widgets.Aerc, args []string) error {
if err != nil {
return err
}
var (
createParents bool
)
var createParents bool
for _, opt := range opts {
switch opt.Option {
case 'p':
@ -61,8 +59,8 @@ func (Move) Execute(aerc *widgets.Aerc, args []string) error {
findNextNonDeleted(uids, store)
joinedArgs := strings.Join(args[optind:], " ")
store.Move(uids, joinedArgs, createParents, func(
msg types.WorkerMessage) {
msg types.WorkerMessage,
) {
switch msg := msg.(type) {
case *types.Done:
aerc.PushStatus("Message moved to "+joinedArgs, 10*time.Second)

View file

@ -4,9 +4,7 @@ import (
"git.sr.ht/~rjarry/aerc/commands"
)
var (
MessageCommands *commands.Commands
)
var MessageCommands *commands.Commands
func register(cmd commands.Command) {
if MessageCommands == nil {

View file

@ -36,7 +36,6 @@ func (FlagMsg) Complete(aerc *widgets.Aerc, args []string) []string {
// If this was called as 'read' or 'unread', it has the same effect as
// 'flag' or 'unflag', respectively, but the 'Seen' flag is affected.
func (FlagMsg) Execute(aerc *widgets.Aerc, args []string) error {
// The flag to change
var flag models.Flag
// User-readable name of the flag to change
@ -184,7 +183,8 @@ func (FlagMsg) Execute(aerc *widgets.Aerc, args []string) error {
func submitFlagChange(aerc *widgets.Aerc, store *lib.MessageStore,
uids []uint32, flag models.Flag, newState bool,
wg *sync.WaitGroup, success *bool) {
wg *sync.WaitGroup, success *bool,
) {
store.Flag(uids, flag, newState, func(msg types.WorkerMessage) {
wg.Add(1)
switch msg := msg.(type) {

View file

@ -136,7 +136,6 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
)
aerc.AddDialog(confirm)
}
})
}
@ -212,9 +211,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error {
mu.Unlock()
})
}
})
})
return nil

View file

@ -285,7 +285,8 @@ func setReferencesHeader(target, parent *mail.Header) error {
// addMimeType adds the proper mime type of the part to the originalMail struct
func addMimeType(msg *models.MessageInfo, part []int,
orig *models.OriginalMail) error {
orig *models.OriginalMail,
) error {
// caution, :forward uses the code as well, keep that in mind when modifying
bs, err := msg.BodyStructure.PartAtIndex(part)
if err != nil {

View file

@ -18,10 +18,12 @@ func TestParseUnsubscribe(t *testing.T) {
{"<https://example.com> is a URL", []string{
"https://example.com",
}},
{"<mailto:user@host?subject=unsubscribe>, <https://example.com>",
{
"<mailto:user@host?subject=unsubscribe>, <https://example.com>",
[]string{
"mailto:user@host?subject=unsubscribe", "https://example.com",
}},
},
},
{"<>, <https://example> ", []string{
"", "https://example",
}},

View file

@ -4,9 +4,7 @@ import (
"git.sr.ht/~rjarry/aerc/commands"
)
var (
MessageViewCommands *commands.Commands
)
var MessageViewCommands *commands.Commands
func register(cmd commands.Command) {
if MessageViewCommands == nil {

View file

@ -129,7 +129,6 @@ func savePart(
aerc *widgets.Aerc,
params *saveParams,
) error {
if params.trailingSlash || isDirExists(path) {
filename := generateFilename(pi.Part)
path = filepath.Join(path, filename)
@ -137,7 +136,7 @@ func savePart(
dir := filepath.Dir(path)
if params.createDirs && dir != "" {
err := os.MkdirAll(dir, 0755)
err := os.MkdirAll(dir, 0o755)
if err != nil {
return err
}

View file

@ -2,8 +2,9 @@ package commands
import (
"fmt"
"git.sr.ht/~rjarry/aerc/widgets"
"strings"
"git.sr.ht/~rjarry/aerc/widgets"
)
type Prompt struct{}

View file

@ -21,7 +21,6 @@ func init() {
func (Set) Aliases() []string {
return []string{"set"}
}
func (Set) Complete(aerc *widgets.Aerc, args []string) []string {
@ -48,7 +47,6 @@ func SetCore(aerc *widgets.Aerc, args []string) error {
new_file := ini.Empty()
section, err := new_file.NewSection(category)
if err != nil {
return nil
}

View file

@ -4,9 +4,7 @@ import (
"git.sr.ht/~rjarry/aerc/commands"
)
var (
TerminalCommands *commands.Commands
)
var TerminalCommands *commands.Commands
func register(cmd commands.Command) {
if TerminalCommands == nil {

View file

@ -56,8 +56,8 @@ func MergeBindings(bindings ...*KeyBindings) *KeyBindings {
}
func (config AercConfig) MergeContextualBinds(baseBinds *KeyBindings,
contextType ContextType, reg string, bindCtx string) *KeyBindings {
contextType ContextType, reg string, bindCtx string,
) *KeyBindings {
bindings := baseBinds
for _, contextualBind := range config.ContextualBinds {
if contextualBind.ContextType != contextType {
@ -83,8 +83,8 @@ func (bindings *KeyBindings) Add(binding *Binding) {
}
func (bindings *KeyBindings) GetBinding(
input []KeyStroke) (BindingSearchResult, []KeyStroke) {
input []KeyStroke,
) (BindingSearchResult, []KeyStroke) {
incomplete := false
// TODO: This could probably be a sorted list to speed things up
// TODO: Deal with bindings that share a prefix
@ -165,9 +165,7 @@ func FormatKeyStrokes(keystrokes []KeyStroke) string {
return sb.String()
}
var (
keyNames map[string]KeyStroke
)
var keyNames map[string]KeyStroke
func ParseKeyStrokes(keystrokes string) ([]KeyStroke, error) {
var strokes []KeyStroke

View file

@ -398,7 +398,7 @@ var searchDirs = buildDefaultDirs()
func installTemplate(root, name string) error {
var err error
if _, err = os.Stat(root); os.IsNotExist(err) {
err = os.MkdirAll(root, 0755)
err = os.MkdirAll(root, 0o755)
if err != nil {
return err
}
@ -413,7 +413,7 @@ func installTemplate(root, name string) error {
if err != nil {
return err
}
err = ioutil.WriteFile(path.Join(root, name), data, 0644)
err = ioutil.WriteFile(path.Join(root, name), data, 0o644)
if err != nil {
return err
}
@ -527,8 +527,7 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
if err := validateBorderChars(uiSection, &uiSubConfig); err != nil {
return err
}
contextualUi :=
UIConfigContext{
contextualUi := UIConfigContext{
UiConfig: uiSubConfig,
}
@ -922,7 +921,6 @@ func LoadBindingSection(sec *ini.Section) (*KeyBindings, error) {
}
func (config *AercConfig) LoadBinds(binds *ini.File, baseName string, baseGroup **KeyBindings) error {
if sec, err := binds.GetSection(baseName); err == nil {
binds, err := LoadBindingSection(sec)
if err != nil {
@ -947,8 +945,7 @@ func (config *AercConfig) LoadBinds(binds *ini.File, baseName string, baseGroup
return err
}
contextualBind :=
BindingConfigContext{
contextualBind := BindingConfigContext{
Bindings: binds,
BindContext: baseName,
}
@ -1006,7 +1003,7 @@ func checkConfigPerms(filename string) error {
perms := info.Mode().Perm()
// group or others have read access
if perms&044 != 0 {
if perms&0o44 != 0 {
fmt.Fprintf(os.Stderr, "The file %v has too open permissions.\n", filename)
fmt.Fprintln(os.Stderr, "This is a security issue (it contains passwords).")
fmt.Fprintf(os.Stderr, "To fix it, run `chmod 600 %v`\n", filename)
@ -1035,7 +1032,8 @@ func (ui *UIConfig) loadStyleSet(styleSetDirs []string) error {
}
func (config AercConfig) mergeContextualUi(baseUi UIConfig,
contextType ContextType, s string) UIConfig {
contextType ContextType, s string,
) UIConfig {
for _, contextualUi := range config.ContextualUis {
if contextualUi.ContextType != contextType {
continue
@ -1078,7 +1076,8 @@ func (uiConfig UIConfig) GetStyleSelected(so StyleObject) tcell.Style {
}
func (uiConfig UIConfig) GetComposedStyle(base StyleObject,
styles []StyleObject) tcell.Style {
styles []StyleObject,
) tcell.Style {
return uiConfig.style.Compose(base, styles)
}

View file

@ -265,7 +265,8 @@ func (ss StyleSet) Compose(so StyleObject, sos []StyleObject) tcell.Style {
}
func (ss StyleSet) ComposeSelected(so StyleObject,
sos []StyleObject) tcell.Style {
sos []StyleObject,
) tcell.Style {
base := *ss.selected[so]
styles := make([]*Style, len(sos))
for i, so := range sos {

View file

@ -12,8 +12,8 @@ import (
)
func (trig *TriggersConfig) ExecTrigger(triggerCmd string,
triggerFmt func(string) (string, error)) error {
triggerFmt func(string) (string, error),
) error {
if len(triggerCmd) == 0 {
return errors.New("Trigger command empty")
}
@ -34,7 +34,8 @@ func (trig *TriggersConfig) ExecTrigger(triggerCmd string,
}
func (trig *TriggersConfig) ExecNewEmail(account *AccountConfig,
conf *AercConfig, msg *models.MessageInfo) {
conf *AercConfig, msg *models.MessageInfo,
) {
err := trig.ExecTrigger(trig.NewEmail,
func(part string) (string, error) {
formatstr, args, err := format.ParseMessageFormat(
@ -45,7 +46,8 @@ func (trig *TriggersConfig) ExecNewEmail(account *AccountConfig,
format.Ctx{
FromAddress: account.From,
AccountName: account.Name,
MsgInfo: msg},
MsgInfo: msg,
},
)
if err != nil {
return "", err

View file

@ -26,7 +26,6 @@ func (cr *Reply) AddOrganizer(o string) {
// CreateReply parses a ics request and return a ics reply (RFC 2446, Section 3.2.3)
func CreateReply(reader io.Reader, from *mail.Address, partstat string) (*Reply, error) {
cr := Reply{
MimeType: "text/calendar",
Params: map[string]string{

View file

@ -37,7 +37,6 @@ func (m *Mail) ImportKeys(r io.Reader) error {
}
func (m *Mail) Encrypt(buf *bytes.Buffer, rcpts []string, signer string, decryptKeys openpgp.PromptFunction, header *mail.Header) (io.WriteCloser, error) {
return Encrypt(buf, header.Header.Header, rcpts, signer)
}

View file

@ -31,10 +31,10 @@ var (
func (m *Mail) Init() error {
logging.Infof("Initializing PGP keyring")
os.MkdirAll(path.Join(xdg.DataHome(), "aerc"), 0700)
os.MkdirAll(path.Join(xdg.DataHome(), "aerc"), 0o700)
lockpath := path.Join(xdg.DataHome(), "aerc", "keyring.lock")
lockfile, err := os.OpenFile(lockpath, os.O_CREATE|os.O_EXCL, 0600)
lockfile, err := os.OpenFile(lockpath, os.O_CREATE|os.O_EXCL, 0o600)
if err != nil {
// TODO: Consider connecting to main process over IPC socket
locked = false
@ -149,7 +149,7 @@ func (m *Mail) ImportKeys(r io.Reader) error {
Keyring = append(Keyring, keys...)
if locked {
keypath := path.Join(xdg.DataHome(), "aerc", "keyring.asc")
keyfile, err := os.OpenFile(keypath, os.O_CREATE|os.O_APPEND, 0600)
keyfile, err := os.OpenFile(keypath, os.O_CREATE|os.O_APPEND, 0o600)
if err != nil {
return err
}

View file

@ -81,7 +81,8 @@ type Ctx struct {
func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
thisWeekTimeFmt string, thisYearTimeFmt string, ctx Ctx) (
string, []interface{}, error) {
string, []interface{}, error,
) {
retval := make([]byte, 0, len(format))
var args []interface{}
@ -289,10 +290,10 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
}
case 'Z':
// calculate all flags
var readReplyFlag = ""
var delFlag = ""
var flaggedFlag = ""
var markedFlag = ""
readReplyFlag := ""
delFlag := ""
flaggedFlag := ""
markedFlag := ""
seen := false
recent := false
answered := false
@ -390,7 +391,8 @@ handle_end_error:
}
func dummyIfZeroDate(date time.Time, format string, todayFormat string,
thisWeekFormat string, thisYearFormat string) string {
thisWeekFormat string, thisYearFormat string,
) string {
if date.IsZero() {
return strings.Repeat("?", len(format))
}

View file

@ -62,10 +62,12 @@ type MessageStoreView struct {
func NewMessageStoreView(messageInfo *models.MessageInfo,
store *MessageStore, pgp crypto.Provider, decryptKeys openpgp.PromptFunction,
cb func(MessageView, error)) {
msv := &MessageStoreView{messageInfo, store,
nil, nil, messageInfo.BodyStructure}
cb func(MessageView, error),
) {
msv := &MessageStoreView{
messageInfo, store,
nil, nil, messageInfo.BodyStructure,
}
if usePGP(messageInfo.BodyStructure) {
store.FetchFull([]uint32{messageInfo.Uid}, func(fm *types.FullMessage) {
@ -117,7 +119,6 @@ func (msv *MessageStoreView) MessageDetails() *models.MessageDetails {
}
func (msv *MessageStoreView) FetchBodyPart(part []int, cb func(io.Reader)) {
if msv.message == nil {
msv.messageStore.FetchBodyPart(msv.messageInfo.Uid, part, cb)
return

View file

@ -68,8 +68,8 @@ func NewMessageStore(worker *types.Worker,
defaultSortCriteria []*types.SortCriterion,
thread bool, clientThreads bool, clientThreadsDelay time.Duration,
triggerNewEmail func(*models.MessageInfo),
triggerDirectoryChange func()) *MessageStore {
triggerDirectoryChange func(),
) *MessageStore {
if !dirInfo.Caps.Thread {
clientThreads = true
}
@ -102,8 +102,8 @@ func NewMessageStore(worker *types.Worker,
}
func (store *MessageStore) FetchHeaders(uids []uint32,
cb func(*types.MessageInfo)) {
cb func(*types.MessageInfo),
) {
// TODO: this could be optimized by pre-allocating toFetch and trimming it
// at the end. In practice we expect to get most messages back in one frame.
var toFetch []uint32
@ -166,7 +166,6 @@ func (store *MessageStore) FetchFull(uids []uint32, cb func(*types.FullMessage))
}
func (store *MessageStore) FetchBodyPart(uid uint32, part []int, cb func(io.Reader)) {
store.worker.PostAction(&types.FetchMessageBodyPart{
Uid: uid,
Part: part,
@ -399,7 +398,6 @@ func (store *MessageStore) runThreadBuilder() {
}
}
store.threadBuilderDebounce = time.AfterFunc(store.threadBuilderDelay, func() {
// temporarily deactiviate the selector in the message list by
// setting SelectedUid to the MagicUid
oldUid := store.SelectedUid()
@ -436,8 +434,8 @@ func (store *MessageStore) runThreadBuilder() {
}
func (store *MessageStore) Delete(uids []uint32,
cb func(msg types.WorkerMessage)) {
cb func(msg types.WorkerMessage),
) {
for _, uid := range uids {
store.Deleted[uid] = nil
}
@ -461,8 +459,8 @@ func (store *MessageStore) revertDeleted(uids []uint32) {
}
func (store *MessageStore) Copy(uids []uint32, dest string, createDest bool,
cb func(msg types.WorkerMessage)) {
cb func(msg types.WorkerMessage),
) {
if createDest {
store.worker.PostAction(&types.CreateDirectory{
Directory: dest,
@ -477,8 +475,8 @@ func (store *MessageStore) Copy(uids []uint32, dest string, createDest bool,
}
func (store *MessageStore) Move(uids []uint32, dest string, createDest bool,
cb func(msg types.WorkerMessage)) {
cb func(msg types.WorkerMessage),
) {
for _, uid := range uids {
store.Deleted[uid] = nil
}
@ -505,8 +503,8 @@ func (store *MessageStore) Move(uids []uint32, dest string, createDest bool,
}
func (store *MessageStore) Flag(uids []uint32, flag models.Flag,
enable bool, cb func(msg types.WorkerMessage)) {
enable bool, cb func(msg types.WorkerMessage),
) {
store.worker.PostAction(&types.FlagMessages{
Enable: enable,
Flag: flag,
@ -515,8 +513,8 @@ func (store *MessageStore) Flag(uids []uint32, flag models.Flag,
}
func (store *MessageStore) Answered(uids []uint32, answered bool,
cb func(msg types.WorkerMessage)) {
cb func(msg types.WorkerMessage),
) {
store.worker.PostAction(&types.AnsweredMessages{
Answered: answered,
Uids: uids,
@ -524,7 +522,6 @@ func (store *MessageStore) Answered(uids []uint32, answered bool,
}
func (store *MessageStore) Uids() []uint32 {
if store.ThreadedView() && store.builder != nil {
if uids := store.builder.Uids(); len(uids) > 0 {
return uids
@ -793,7 +790,8 @@ func (store *MessageStore) PrevResult() {
}
func (store *MessageStore) ModifyLabels(uids []uint32, add, remove []string,
cb func(msg types.WorkerMessage)) {
cb func(msg types.WorkerMessage),
) {
store.worker.PostAction(&types.ModifyLabels{
Uids: uids,
Add: add,

View file

@ -3,6 +3,7 @@ package lib
import (
"context"
"fmt"
"github.com/emersion/go-imap/client"
"github.com/emersion/go-sasl"
"golang.org/x/oauth2"

View file

@ -29,7 +29,6 @@ func NewXDGOpen(filename string) *xdgOpen {
errCh: errch,
args: []string{filename},
}
}
// SetArgs sets additional arguments to the open command prior to the filename

View file

@ -8,8 +8,10 @@ import (
"strings"
)
var submatch = `(https?:\/\/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,10}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*))`
var httpRe = regexp.MustCompile("\"" + submatch + "\"" + "|" + "\\(" + submatch + "\\)" + "|" + "<" + submatch + ">" + "|" + submatch)
var (
submatch = `(https?:\/\/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,10}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*))`
httpRe = regexp.MustCompile("\"" + submatch + "\"" + "|" + "\\(" + submatch + "\\)" + "|" + "<" + submatch + ">" + "|" + submatch)
)
// HttpLinks searches a reader for a http link and returns a copy of the
// reader and a slice with links.
@ -36,7 +38,7 @@ func HttpLinks(r io.Reader) (io.Reader, []string) {
}
results := []string{}
for link, _ := range linkMap {
for link := range linkMap {
results = append(results, link)
}

View file

@ -32,7 +32,8 @@ type folderState struct {
}
func NewState(name string, multipleAccts bool, conf config.StatuslineConfig) *State {
return &State{separator: conf.Separator,
return &State{
separator: conf.Separator,
renderer: newRenderer(conf.RenderFormat, conf.DisplayMode),
acct: &accountState{Name: name, Multiple: multipleAccts},
fldr: make(map[string]*folderState),

View file

@ -8,27 +8,26 @@ import (
)
func TestLib_FindAllNonMultipart(t *testing.T) {
testStructure := &models.BodyStructure{
MIMEType: "multipart",
Parts: []*models.BodyStructure{
&models.BodyStructure{},
&models.BodyStructure{
{},
{
MIMEType: "multipart",
Parts: []*models.BodyStructure{
&models.BodyStructure{},
&models.BodyStructure{},
{},
{},
},
},
&models.BodyStructure{},
{},
},
}
expected := [][]int{
[]int{1},
[]int{2, 1},
[]int{2, 2},
[]int{3},
{1},
{2, 1},
{2, 2},
{3},
}
parts := lib.FindAllNonMultipart(testStructure, nil, nil)
@ -42,5 +41,4 @@ func TestLib_FindAllNonMultipart(t *testing.T) {
t.Errorf("incorrect values; expected: %v, got: %v", expected[i], parts[i])
}
}
}

View file

@ -22,7 +22,8 @@ type Bordered struct {
}
func NewBordered(
content Drawable, borders uint, uiConfig *config.UIConfig) *Bordered {
content Drawable, borders uint, uiConfig *config.UIConfig,
) *Bordered {
b := &Bordered{
borders: borders,
content: content,

View file

@ -63,7 +63,8 @@ func (ctx *Context) SetCell(x, y int, ch rune, style tcell.Style) {
}
func (ctx *Context) Printf(x, y int, style tcell.Style,
format string, a ...interface{}) int {
format string, a ...interface{},
) int {
width, height := ctx.viewport.Size()
if x >= width || y >= height {

View file

@ -36,8 +36,10 @@ type Tab struct {
uiConf *config.UIConfig
}
type TabStrip Tabs
type TabContent Tabs
type (
TabStrip Tabs
TabContent Tabs
)
func NewTabs(uiConf *config.UIConfig) *Tabs {
tabs := &Tabs{}

View file

@ -59,7 +59,8 @@ func (ti *TextInput) Prompt(prompt string) *TextInput {
}
func (ti *TextInput) TabComplete(
tabcomplete func(s string) ([]string, string), d time.Duration) *TextInput {
tabcomplete func(s string) ([]string, string), d time.Duration,
) *TextInput {
ti.tabcomplete = tabcomplete
ti.completeDelay = d
return ti

View file

@ -19,7 +19,6 @@ type UI struct {
}
func Initialize(content DrawableInteractive) (*UI, error) {
screen, err := tcell.NewScreen()
if err != nil {
return nil, err

View file

@ -506,7 +506,7 @@ func (wizard *AccountWizard) finish(tutorial bool) {
}
if !wizard.temporary {
f, err := os.OpenFile(accountsConf, os.O_WRONLY|os.O_CREATE, 0600)
f, err := os.OpenFile(accountsConf, os.O_WRONLY|os.O_CREATE, 0o600)
if err != nil {
wizard.errorFor(nil, err)
return

View file

@ -51,7 +51,8 @@ type Choice struct {
func NewAerc(conf *config.AercConfig,
crypto crypto.Provider, cmd func(cmd []string) error,
complete func(cmd string) []string, cmdHistory lib.History,
deferLoop chan struct{}) *Aerc {
deferLoop chan struct{},
) *Aerc {
tabs := ui.NewTabs(&conf.Ui)
statusbar := ui.NewStack(conf.Ui)

View file

@ -65,8 +65,8 @@ type Composer struct {
func NewComposer(aerc *Aerc, acct *AccountView, conf *config.AercConfig,
acctConfig *config.AccountConfig, worker *types.Worker, template string,
h *mail.Header, orig models.OriginalMail) (*Composer, error) {
h *mail.Header, orig models.OriginalMail,
) (*Composer, error) {
if h == nil {
h = new(mail.Header)
}
@ -78,7 +78,6 @@ func NewComposer(aerc *Aerc, acct *AccountView, conf *config.AercConfig,
}
if fl != nil {
h.SetAddressList("from", fl)
}
}
@ -134,7 +133,6 @@ func NewComposer(aerc *Aerc, acct *AccountView, conf *config.AercConfig,
}
func (c *Composer) buildComposeHeader(aerc *Aerc, cmpl *completer.Completer) {
c.layout = aerc.conf.Compose.HeaderLayout
c.editors = make(map[string]*headerEditor)
c.focusable = make([]ui.MouseableDrawableInteractive, 0)
@ -594,7 +592,7 @@ func getRecipientsEmail(c *Composer) ([]string, error) {
// return email addresses as string slice
results := []string{}
for email, _ := range rcpts {
for email := range rcpts {
results = append(results, email)
}
return results, nil
@ -933,7 +931,8 @@ type headerEditor struct {
}
func newHeaderEditor(name string, h *mail.Header,
uiConfig *config.UIConfig) *headerEditor {
uiConfig *config.UIConfig,
) *headerEditor {
he := &headerEditor{
input: ui.NewTextInput("", uiConfig),
name: name,

View file

@ -119,7 +119,6 @@ func (dirlist *DirectoryList) UpdateList(done func(dirs []string)) {
var dirs []string
dirlist.worker.PostAction(
&types.ListDirectories{}, func(msg types.WorkerMessage) {
switch msg := msg.(type) {
case *types.Directory:
dirs = append(dirs, msg.Dir.Name)

View file

@ -383,7 +383,7 @@ func buildTree(node *types.Thread, stree [][]string, defaultUid uint32) {
}
}
keys := make([]string, 0)
for key, _ := range m {
for key := range m {
keys = append(keys, key)
}
sort.Strings(keys)

View file

@ -20,8 +20,8 @@ type ExLine struct {
func NewExLine(conf *config.AercConfig, cmd string, commit func(cmd string), finish func(),
tabcomplete func(cmd string) ([]string, string),
cmdHistory lib.History) *ExLine {
cmdHistory lib.History,
) *ExLine {
input := ui.NewTextInput("", &conf.Ui).Prompt(":").Set(cmd)
if conf.Ui.CompletionPopovers {
input.TabComplete(tabcomplete, conf.Ui.CompletionDelay)
@ -41,8 +41,8 @@ func NewExLine(conf *config.AercConfig, cmd string, commit func(cmd string), fin
}
func NewPrompt(conf *config.AercConfig, prompt string, commit func(text string),
tabcomplete func(cmd string) ([]string, string)) *ExLine {
tabcomplete func(cmd string) ([]string, string),
) *ExLine {
input := ui.NewTextInput("", &conf.Ui).Prompt(prompt)
if conf.Ui.CompletionPopovers {
input.TabComplete(tabcomplete, conf.Ui.CompletionDelay)

View file

@ -19,7 +19,8 @@ type GetPasswd struct {
}
func NewGetPasswd(title string, prompt string, conf *config.AercConfig,
cb func(string, error)) *GetPasswd {
cb func(string, error),
) *GetPasswd {
getpasswd := &GetPasswd{
callback: cb,
title: title,

View file

@ -52,8 +52,8 @@ type PartSwitcher struct {
}
func NewMessageViewer(acct *AccountView,
conf *config.AercConfig, msg lib.MessageView) *MessageViewer {
conf *config.AercConfig, msg lib.MessageView,
) *MessageViewer {
hf := HeaderLayoutFilter{
layout: HeaderLayout(conf.Viewer.HeaderLayout),
keep: func(msg *models.MessageInfo, header string) bool {
@ -178,8 +178,8 @@ func fmtHeader(msg *models.MessageInfo, header string, timefmt string) string {
func enumerateParts(acct *AccountView, conf *config.AercConfig,
msg lib.MessageView, body *models.BodyStructure,
index []int) ([]*PartViewer, error) {
index []int,
) ([]*PartViewer, error) {
var parts []*PartViewer
for i, part := range body.Parts {
curindex := append(index, i+1)
@ -205,8 +205,8 @@ func enumerateParts(acct *AccountView, conf *config.AercConfig,
}
func createSwitcher(acct *AccountView, switcher *PartSwitcher,
conf *config.AercConfig, msg lib.MessageView) error {
conf *config.AercConfig, msg lib.MessageView,
) error {
var err error
switcher.selected = -1
switcher.showHeaders = conf.Viewer.ShowHeaders
@ -530,8 +530,8 @@ type PartViewer struct {
func NewPartViewer(acct *AccountView, conf *config.AercConfig,
msg lib.MessageView, part *models.BodyStructure,
index []int) (*PartViewer, error) {
index []int,
) (*PartViewer, error) {
var (
filter *exec.Cmd
pager *exec.Cmd

View file

@ -64,5 +64,4 @@ func (s *Scrollable) EnsureScroll(selectingIdx int) {
if s.scroll > maxScroll {
s.scroll = maxScroll
}
}

View file

@ -176,7 +176,8 @@ type SelectorDialog struct {
}
func NewSelectorDialog(title string, prompt string, options []string, focus int,
uiConfig *config.UIConfig, cb func(string, error)) *SelectorDialog {
uiConfig *config.UIConfig, cb func(string, error),
) *SelectorDialog {
sd := &SelectorDialog{
callback: cb,
title: title,

View file

@ -82,8 +82,7 @@ func init() {
keyMap[tcell.KeyPgUp] = directKey(vterm.KeyPageUp)
keyMap[tcell.KeyPgDn] = directKey(vterm.KeyPageDown)
for i := 0; i < 64; i++ {
keyMap[tcell.Key(int(tcell.KeyF1)+i)] =
directKey(vterm.Key(int(vterm.KeyFunction0) + i + 1))
keyMap[tcell.Key(int(tcell.KeyF1)+i)] = directKey(vterm.Key(int(vterm.KeyFunction0) + i + 1))
}
keyMap[tcell.KeyTAB] = directKey(vterm.KeyTab)
keyMap[tcell.KeyESC] = directKey(vterm.KeyEscape)
@ -302,7 +301,6 @@ func (term *Terminal) Draw(ctx *ui.Context) {
term.damageMutex.Lock()
for _, rect := range term.damage {
for x := rect.StartCol(); x < rect.EndCol() && x < ctx.Width(); x += 1 {
for y := rect.StartRow(); y < rect.EndRow() && y < ctx.Height(); y += 1 {
coords := coords{x, y}
@ -472,8 +470,8 @@ func (term *Terminal) onDamage(rect *vterm.Rect) int {
}
func (term *Terminal) onMoveCursor(old *vterm.Pos,
pos *vterm.Pos, visible bool) int {
pos *vterm.Pos, visible bool,
) int {
rows, cols, _ := pty.Getsize(term.pty)
if pos.Row() >= rows || pos.Col() >= cols {
return 1

View file

@ -16,7 +16,6 @@ import (
// selects the default inbox. If no error is returned, the imap client will be
// in the imap.SelectedState.
func (w *IMAPWorker) connect() (*client.Client, error) {
var (
conn *net.TCPConn
err error
@ -98,8 +97,7 @@ func (w *IMAPWorker) connect() (*client.Client, error) {
// but a valid connection is eventually returned, ensure that it is properly
// closed.
func newTCPConn(addr string, timeout time.Duration) (*net.TCPConn, error) {
var errTCPTimeout = fmt.Errorf("tcp connection timeout")
errTCPTimeout := fmt.Errorf("tcp connection timeout")
type tcpConn struct {
conn *net.TCPConn

View file

@ -16,7 +16,8 @@ import (
)
func (imapw *IMAPWorker) handleFetchMessageHeaders(
msg *types.FetchMessageHeaders) {
msg *types.FetchMessageHeaders,
) {
toFetch := msg.Uids
if imapw.config.cacheEnabled && imapw.cache != nil {
toFetch = imapw.getCachedHeaders(msg)
@ -76,8 +77,8 @@ func (imapw *IMAPWorker) handleFetchMessageHeaders(
}
func (imapw *IMAPWorker) handleFetchMessageBodyPart(
msg *types.FetchMessageBodyPart) {
msg *types.FetchMessageBodyPart,
) {
logging.Infof("Fetching message %d part: %v", msg.Uid, msg.Part)
var partHeaderSection imap.BodySectionName
@ -146,8 +147,8 @@ func (imapw *IMAPWorker) handleFetchMessageBodyPart(
}
func (imapw *IMAPWorker) handleFetchFullMessages(
msg *types.FetchFullMessages) {
msg *types.FetchFullMessages,
) {
logging.Infof("Fetching full messages: %v", msg.Uids)
section := &imap.BodySectionName{}
items := []imap.FetchItem{
@ -205,8 +206,8 @@ func (imapw *IMAPWorker) handleFetchMessageFlags(msg *types.FetchMessageFlags) {
func (imapw *IMAPWorker) handleFetchMessages(
msg types.WorkerMessage, uids []uint32, items []imap.FetchItem,
procFunc func(*imap.Message) error) {
procFunc func(*imap.Message) error,
) {
messages := make(chan *imap.Message)
done := make(chan error)

View file

@ -79,5 +79,4 @@ func (imapw *IMAPWorker) handleSearchDirectory(msg *types.SearchDirectory) {
Message: types.RespondTo(msg),
Uids: uids,
}, nil)
}

View file

@ -38,7 +38,6 @@ func (imapw *IMAPWorker) handleAppendMessage(msg *types.AppendMessage) {
Reader: msg.Reader,
Length: msg.Length,
}); err != nil {
imapw.worker.PostMessage(&types.Error{
Message: types.RespondTo(msg),
Error: err,

View file

@ -140,7 +140,8 @@ func (o *observer) DelayedReconnect() error {
func (o *observer) emit(errMsg string) {
o.log("disconnect done->")
o.worker.PostMessage(&types.Done{
Message: types.RespondTo(&types.Disconnect{})}, nil)
Message: types.RespondTo(&types.Disconnect{}),
}, nil)
o.log("connection error->")
o.worker.PostMessage(&types.ConnError{
Error: fmt.Errorf(errMsg),

View file

@ -25,8 +25,8 @@ func (imapw *IMAPWorker) handleOpenDirectory(msg *types.OpenDirectory) {
}
func (imapw *IMAPWorker) handleFetchDirectoryContents(
msg *types.FetchDirectoryContents) {
msg *types.FetchDirectoryContents,
) {
logging.Infof("Fetching UID list")
searchCriteria, err := parseSearch(msg.FilterCriteria)
@ -88,7 +88,8 @@ var sortFieldMap sortFieldMapT = sortFieldMapT{
}
func translateSortCriterions(
cs []*types.SortCriterion) []sortthread.SortCriterion {
cs []*types.SortCriterion,
) []sortthread.SortCriterion {
result := make([]sortthread.SortCriterion, 0, len(cs))
for _, c := range cs {
if f, ok := sortFieldMap[c.Field]; ok {
@ -99,7 +100,8 @@ func translateSortCriterions(
}
func (imapw *IMAPWorker) handleDirectoryThreaded(
msg *types.FetchDirectoryThreaded) {
msg *types.FetchDirectoryThreaded,
) {
logging.Infof("Fetching threaded UID list")
searchCriteria, err := parseSearch(msg.FilterCriteria)

View file

@ -97,8 +97,8 @@ func Search(messages []RawMessage, criteria *searchCriteria) ([]uint32, error) {
// searchMessage executes the search criteria for the given RawMessage,
// returns true if search succeeded
func searchMessage(message RawMessage, criteria *searchCriteria,
parts MsgParts) (bool, error) {
parts MsgParts,
) (bool, error) {
// setup parts of the message to use in the search
// this is so that we try to minimise reading unnecessary parts
var (

View file

@ -10,7 +10,8 @@ import (
)
func Sort(messageInfos []*models.MessageInfo,
criteria []*types.SortCriterion) ([]uint32, error) {
criteria []*types.SortCriterion,
) ([]uint32, error) {
// loop through in reverse to ensure we sort by non-primary fields first
for i := len(criteria) - 1; i >= 0; i-- {
criterion := criteria[i]
@ -62,7 +63,8 @@ func Sort(messageInfos []*models.MessageInfo,
}
func sortAddresses(messageInfos []*models.MessageInfo, criterion *types.SortCriterion,
getValue func(*models.MessageInfo) []*mail.Address) {
getValue func(*models.MessageInfo) []*mail.Address,
) {
sortSlice(criterion, messageInfos, func(i, j int) bool {
addressI, addressJ := getValue(messageInfos[i]), getValue(messageInfos[j])
var firstI, firstJ *mail.Address
@ -92,7 +94,8 @@ func sortAddresses(messageInfos []*models.MessageInfo, criterion *types.SortCrit
}
func sortFlags(messageInfos []*models.MessageInfo, criterion *types.SortCriterion,
testFlag models.Flag) {
testFlag models.Flag,
) {
var slice []*boolStore
for _, msgInfo := range messageInfos {
flagPresent := false
@ -116,7 +119,8 @@ func sortFlags(messageInfos []*models.MessageInfo, criterion *types.SortCriterio
}
func sortStrings(messageInfos []*models.MessageInfo, criterion *types.SortCriterion,
getValue func(*models.MessageInfo) string) {
getValue func(*models.MessageInfo) string,
) {
var slice []*lexiStore
for _, msgInfo := range messageInfos {
slice = append(slice, &lexiStore{

View file

@ -35,8 +35,10 @@ func NewContainer(dir string, maildirpp bool) (*Container, error) {
if !s.IsDir() {
return nil, fmt.Errorf("Given maildir '%s' not a directory", dir)
}
return &Container{dir: dir, uids: uidstore.NewStore(),
recentUIDS: make(map[uint32]struct{}), maildirpp: maildirpp}, nil
return &Container{
dir: dir, uids: uidstore.NewStore(),
recentUIDS: make(map[uint32]struct{}), maildirpp: maildirpp,
}, nil
}
// ListFolders returns a list of maildir folders in the container
@ -183,7 +185,8 @@ func (c *Container) DeleteAll(d maildir.Dir, uids []uint32) ([]uint32, error) {
}
func (c *Container) CopyAll(
dest maildir.Dir, src maildir.Dir, uids []uint32) error {
dest maildir.Dir, src maildir.Dir, uids []uint32,
) error {
for _, uid := range uids {
if err := c.copyMessage(dest, src, uid); err != nil {
return fmt.Errorf("could not copy message %d: %v", uid, err)
@ -193,7 +196,8 @@ func (c *Container) CopyAll(
}
func (c *Container) copyMessage(
dest maildir.Dir, src maildir.Dir, uid uint32) error {
dest maildir.Dir, src maildir.Dir, uid uint32,
) error {
key, ok := c.uids.GetKey(uid)
if !ok {
return fmt.Errorf("could not find key for message id %d", uid)

View file

@ -111,7 +111,8 @@ func (w *Worker) search(criteria *searchCriteria) ([]uint32, error) {
// Execute the search criteria for the given key, returns true if search succeeded
func (w *Worker) searchKey(key uint32, criteria *searchCriteria,
parts MsgParts) (bool, error) {
parts MsgParts,
) (bool, error) {
message, err := w.c.Message(*w.selected, key)
if err != nil {
return false, err

View file

@ -406,7 +406,8 @@ func (w *Worker) handleOpenDirectory(msg *types.OpenDirectory) error {
}
func (w *Worker) handleFetchDirectoryContents(
msg *types.FetchDirectoryContents) error {
msg *types.FetchDirectoryContents,
) error {
var (
uids []uint32
err error
@ -482,7 +483,8 @@ func (w *Worker) handleRemoveDirectory(msg *types.RemoveDirectory) error {
}
func (w *Worker) handleFetchMessageHeaders(
msg *types.FetchMessageHeaders) error {
msg *types.FetchMessageHeaders,
) error {
for _, uid := range msg.Uids {
info, err := w.msgInfoFromUid(uid)
if err != nil {
@ -500,8 +502,8 @@ func (w *Worker) handleFetchMessageHeaders(
}
func (w *Worker) handleFetchMessageBodyPart(
msg *types.FetchMessageBodyPart) error {
msg *types.FetchMessageBodyPart,
) error {
// get reader
m, err := w.c.Message(*w.selected, msg.Uid)
if err != nil {

View file

@ -8,7 +8,6 @@ import (
)
func createMailboxContainer(path string) (*mailboxContainer, error) {
file, err := os.Open(path)
if err != nil {
return nil, err

View file

@ -99,7 +99,8 @@ func (w *mboxWorker) handleMessage(msg types.WorkerMessage) error {
if !ok {
w.folder = w.data.Create(w.name)
w.worker.PostMessage(&types.Done{
Message: types.RespondTo(&types.CreateDirectory{})}, nil)
Message: types.RespondTo(&types.CreateDirectory{}),
}, nil)
}
w.worker.PostMessage(&types.DirectoryInfo{
Info: w.data.DirectoryInfo(msg.Directory),
@ -338,7 +339,8 @@ func (w *mboxWorker) handleMessage(msg types.WorkerMessage) error {
if !ok {
folder = w.data.Create(msg.Destination)
w.worker.PostMessage(&types.Done{
Message: types.RespondTo(&types.CreateDirectory{})}, nil)
Message: types.RespondTo(&types.CreateDirectory{}),
}, nil)
}
if err := folder.Append(msg.Reader, msg.Flags); err != nil {

View file

@ -225,7 +225,8 @@ func (db *DB) MsgTags(key string) ([]string, error) {
}
func (db *DB) msgModify(key string,
cb func(*notmuch.Message) error) error {
cb func(*notmuch.Message) error,
) error {
err := db.withConnection(true, func(ndb *notmuch.DB) error {
msg, err := ndb.FindMessage(key)
if err != nil {
@ -281,7 +282,8 @@ func (db *DB) KeyFromUid(uid uint32) (string, bool) {
}
func (db *DB) enumerateThread(nt *notmuch.Threads,
valid map[string]struct{}) ([]*types.Thread, error) {
valid map[string]struct{},
) ([]*types.Thread, error) {
var res []*types.Thread
var thread *notmuch.Thread
for nt.Next(&thread) {
@ -292,7 +294,8 @@ func (db *DB) enumerateThread(nt *notmuch.Threads,
}
func (db *DB) makeThread(parent *types.Thread, msgs *notmuch.Messages,
valid map[string]struct{}) *types.Thread {
valid map[string]struct{},
) *types.Thread {
var lastSibling *types.Thread
var msg *notmuch.Message
for msgs.Next(&msg) {

View file

@ -51,8 +51,10 @@ type worker struct {
// NewWorker creates a new notmuch worker with the provided worker.
func NewWorker(w *types.Worker) (types.Backend, error) {
events := make(chan eventType, 20)
return &worker{w: w,
nmEvents: events}, nil
return &worker{
w: w,
nmEvents: events,
}, nil
}
// Run starts the worker's message handling loop.
@ -92,6 +94,7 @@ func (w *worker) err(msg types.WorkerMessage, err error) {
Error: err,
}, nil)
}
func (w *worker) handleMessage(msg types.WorkerMessage) error {
if w.setupErr != nil {
// only configure can recover from a config error, bail for everything else
@ -211,12 +214,14 @@ func (w *worker) handleListDirectories(msg *types.ListDirectories) error {
}
func (w *worker) gatherDirectoryInfo(name string, query string) (
*types.DirectoryInfo, error) {
*types.DirectoryInfo, error,
) {
return w.buildDirInfo(name, query, false)
}
func (w *worker) buildDirInfo(name string, query string, skipSort bool) (
*types.DirectoryInfo, error) {
*types.DirectoryInfo, error,
) {
count, err := w.db.QueryCountMessages(query)
if err != nil {
return nil, err
@ -281,7 +286,8 @@ func (w *worker) handleOpenDirectory(msg *types.OpenDirectory) error {
}
func (w *worker) handleFetchDirectoryContents(
msg *types.FetchDirectoryContents) error {
msg *types.FetchDirectoryContents,
) error {
w.currentSortCriteria = msg.SortCriteria
err := w.emitDirectoryContents(msg)
if err != nil {
@ -292,7 +298,8 @@ func (w *worker) handleFetchDirectoryContents(
}
func (w *worker) handleFetchDirectoryThreaded(
msg *types.FetchDirectoryThreaded) error {
msg *types.FetchDirectoryThreaded,
) error {
// w.currentSortCriteria = msg.SortCriteria
err := w.emitDirectoryThreaded(msg)
if err != nil {
@ -303,7 +310,8 @@ func (w *worker) handleFetchDirectoryThreaded(
}
func (w *worker) handleFetchMessageHeaders(
msg *types.FetchMessageHeaders) error {
msg *types.FetchMessageHeaders,
) error {
for _, uid := range msg.Uids {
m, err := w.msgFromUid(uid)
if err != nil {
@ -350,8 +358,8 @@ func (w *worker) msgFromUid(uid uint32) (*Message, error) {
}
func (w *worker) handleFetchMessageBodyPart(
msg *types.FetchMessageBodyPart) error {
msg *types.FetchMessageBodyPart,
) error {
m, err := w.msgFromUid(msg.Uid)
if err != nil {
logging.Errorf("could not get message %d: %v", msg.Uid, err)
@ -542,7 +550,8 @@ func (w *worker) loadQueryMap(acctConfig *config.AccountConfig) error {
}
func (w *worker) loadExcludeTags(
acctConfig *config.AccountConfig) []string {
acctConfig *config.AccountConfig,
) []string {
raw, ok := acctConfig.Params["exclude-tags"]
if !ok {
// nothing to do
@ -598,7 +607,8 @@ func (w *worker) emitDirectoryThreaded(parent types.WorkerMessage) error {
}
func (w *worker) emitMessageInfo(m *Message,
parent types.WorkerMessage) error {
parent types.WorkerMessage,
) error {
info, err := m.MessageInfo()
if err != nil {
return fmt.Errorf("could not get MessageInfo: %v", err)
@ -620,7 +630,8 @@ func (w *worker) emitLabelList() {
}
func (w *worker) sort(uids []uint32,
criteria []*types.SortCriterion) ([]uint32, error) {
criteria []*types.SortCriterion,
) ([]uint32, error) {
if len(criteria) == 0 {
return uids, nil
}

View file

@ -113,9 +113,11 @@ func getMaxUID(thread *Thread) uint32 {
func (s ByUID) Len() int {
return len(s)
}
func (s ByUID) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s ByUID) Less(i, j int) bool {
maxUID_i := getMaxUID(s[i])
maxUID_j := getMaxUID(s[j])

View file

@ -36,7 +36,6 @@ func (worker *Worker) setId(msg WorkerMessage) {
}
func (worker *Worker) PostAction(msg WorkerMessage, cb func(msg WorkerMessage)) {
worker.setId(msg)
if resp := msg.InResponseTo(); resp != nil {
@ -52,8 +51,8 @@ func (worker *Worker) PostAction(msg WorkerMessage, cb func(msg WorkerMessage))
}
func (worker *Worker) PostMessage(msg WorkerMessage,
cb func(msg WorkerMessage)) {
cb func(msg WorkerMessage),
) {
worker.setId(msg)
if resp := msg.InResponseTo(); resp != nil {