aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-01-10 17:19:45 +0100
committerDrew DeVault <ddevault@vistarmedia.com>2018-01-10 11:20:41 -0500
commita0be5e80256b98237241b2f3d7825484e7a9c964 (patch)
tree8387b8abc2ad9a81c1ced0d1caa50be7b987e193
parent305446abfd66e85fe2c46cb4a07a3abb9fa809a4 (diff)
downloadaerc-a0be5e80256b98237241b2f3d7825484e7a9c964.tar.gz
Misc idiomatic fixes
-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 845d1767..9188dce6 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 a7e9d849..142a1e00 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 7525da54..6ffdf3ab 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 a5047904..da7928e9 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 {