summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cmd/aerc/main.go13
-rw-r--r--config/config.go24
-rw-r--r--worker/imap/worker.go10
-rw-r--r--worker/worker.go7
4 files changed, 21 insertions, 33 deletions
diff --git a/cmd/aerc/main.go b/cmd/aerc/main.go
index 845d176..9188dce 100644
--- a/cmd/aerc/main.go
+++ b/cmd/aerc/main.go
@@ -10,17 +10,14 @@ import (
 )
 
 func main() {
-	var (
-		conf *config.AercConfig
-		err  error
-	)
-	if conf, err = config.LoadConfig(nil); err != nil {
+	conf, err := config.LoadConfig(nil)
+	if err != nil {
 		panic(err)
 	}
-	workers := make([]worker.Worker, 0)
+	var workers []worker.Worker
 	for _, account := range conf.Accounts {
-		var work worker.Worker
-		if work, err = worker.NewWorker(account.Source); err != nil {
+		work, err := worker.NewWorker(account.Source)
+		if err != nil {
 			panic(err)
 		}
 		fmt.Printf("Initializing worker %s\n", account.Name)
diff --git a/config/config.go b/config/config.go
index a7e9d84..142a1e0 100644
--- a/config/config.go
+++ b/config/config.go
@@ -1,13 +1,13 @@
 package config
 
 import (
-	"github.com/go-ini/ini"
-	"github.com/kyoh86/xdg"
-
 	"fmt"
 	"path"
 	"strings"
 	"unicode"
+
+	"github.com/go-ini/ini"
+	"github.com/kyoh86/xdg"
 )
 
 type UIConfig struct {
@@ -50,16 +50,13 @@ func mapName(raw string) string {
 }
 
 func loadAccountConfig(path string) ([]AccountConfig, error) {
-	var (
-		file     *ini.File
-		err      error
-		accounts []AccountConfig
-	)
-	accounts = make([]AccountConfig, 0)
-	if file, err = ini.Load(path); err != nil {
+	file, err := ini.Load(path)
+	if err != nil {
 		return nil, err
 	}
 	file.NameMapper = mapName
+
+	var accounts []AccountConfig
 	for _, _sec := range file.SectionStrings() {
 		if _sec == "DEFAULT" {
 			continue
@@ -87,15 +84,12 @@ func loadAccountConfig(path string) ([]AccountConfig, error) {
 }
 
 func LoadConfig(root *string) (*AercConfig, error) {
-	var (
-		err  error
-		file *ini.File
-	)
 	if root == nil {
 		_root := path.Join(xdg.ConfigHome(), "aerc")
 		root = &_root
 	}
-	if file, err = ini.Load(path.Join(*root, "aerc.conf")); err != nil {
+	file, err := ini.Load(path.Join(*root, "aerc.conf"))
+	if err != nil {
 		return nil, err
 	}
 	file.NameMapper = mapName
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index 7525da5..6ffdf3a 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -1,10 +1,10 @@
 package imap
 
 import (
-	"git.sr.ht/~sircmpwn/aerc2/worker/types"
-
 	"fmt"
 	"time"
+
+	"git.sr.ht/~sircmpwn/aerc2/worker/types"
 )
 
 type IMAPWorker struct {
@@ -32,15 +32,15 @@ func (w *IMAPWorker) PostAction(msg types.WorkerMessage) {
 	w.actions <- msg
 }
 
-func (w *IMAPWorker) handleMessage(_msg types.WorkerMessage) {
-	switch msg := _msg.(type) {
+func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) {
+	switch msg := msg.(type) {
 	case types.Ping:
 		w.messages <- types.Ack{
 			Message: types.RespondTo(msg),
 		}
 	default:
 		w.messages <- types.Unsupported{
-			Message: types.RespondTo(_msg),
+			Message: types.RespondTo(msg),
 		}
 	}
 }
diff --git a/worker/worker.go b/worker/worker.go
index a504790..da7928e 100644
--- a/worker/worker.go
+++ b/worker/worker.go
@@ -16,11 +16,8 @@ type Worker interface {
 
 // Guesses the appropriate worker type based on the given source string
 func NewWorker(source string) (Worker, error) {
-	var (
-		u   *url.URL
-		err error
-	)
-	if u, err = url.Parse(source); err != nil {
+	u, err := url.Parse(source)
+	if err != nil {
 		return nil, err
 	}
 	switch u.Scheme {