git » chasquid » commit ec95131

Miscellaneous style fixes

author Alberto Bertogli
2019-02-10 12:46:15 UTC
committer Alberto Bertogli
2019-02-10 12:46:15 UTC
parent 582da79eca69614ded2b6736fda1107bda200af3

Miscellaneous style fixes

This patch has some miscellaneous style fixes to issues found by the
staticcheck tool.

There are no functional changes.

internal/aliases/aliases.go +1 -1
internal/auth/auth.go +4 -4
internal/courier/procmail.go +2 -2
internal/dovecot/dovecot.go +1 -1
internal/queue/queue_test.go +0 -18
internal/sts/sts_test.go +0 -1

diff --git a/internal/aliases/aliases.go b/internal/aliases/aliases.go
index 2670999..9902bf1 100644
--- a/internal/aliases/aliases.go
+++ b/internal/aliases/aliases.go
@@ -246,7 +246,7 @@ func (v *Resolver) Reload() error {
 				continue
 			}
 			if err != nil {
-				return fmt.Errorf("Error parsing %q: %v", path, err)
+				return fmt.Errorf("error parsing %q: %v", path, err)
 			}
 
 			// Add the aliases to the resolver, overriding any previous values.
diff --git a/internal/auth/auth.go b/internal/auth/auth.go
index c9b543f..0766e61 100644
--- a/internal/auth/auth.go
+++ b/internal/auth/auth.go
@@ -148,7 +148,7 @@ func DecodeResponse(response string) (user, domain, passwd string, err error) {
 
 	bufsp := bytes.SplitN(buf, []byte{0}, 3)
 	if len(bufsp) != 3 {
-		err = fmt.Errorf("Response pieces != 3, as per RFC")
+		err = fmt.Errorf("response pieces != 3, as per RFC")
 		return
 	}
 
@@ -163,7 +163,7 @@ func DecodeResponse(response string) (user, domain, passwd string, err error) {
 
 		// If neither is empty, then they must be the same.
 		if (z != "" && c != "") && (z != c) {
-			err = fmt.Errorf("Auth IDs do not match")
+			err = fmt.Errorf("auth IDs do not match")
 			return
 		}
 
@@ -176,7 +176,7 @@ func DecodeResponse(response string) (user, domain, passwd string, err error) {
 	}
 
 	if identity == "" {
-		err = fmt.Errorf("Empty identity, must be in the form user@domain")
+		err = fmt.Errorf("empty identity, must be in the form user@domain")
 		return
 	}
 
@@ -184,7 +184,7 @@ func DecodeResponse(response string) (user, domain, passwd string, err error) {
 	// This is NOT an RFC requirement, it's our own.
 	idsp := strings.SplitN(identity, "@", 2)
 	if len(idsp) != 2 {
-		err = fmt.Errorf("Identity must be in the form user@domain")
+		err = fmt.Errorf("identity must be in the form user@domain")
 		return
 	}
 
diff --git a/internal/courier/procmail.go b/internal/courier/procmail.go
index 9f2dc7e..9167a84 100644
--- a/internal/courier/procmail.go
+++ b/internal/courier/procmail.go
@@ -15,7 +15,7 @@ import (
 )
 
 var (
-	errTimeout = fmt.Errorf("Operation timed out")
+	errTimeout = fmt.Errorf("operation timed out")
 )
 
 // Procmail delivers local mail by executing a local binary, like procmail or
@@ -79,7 +79,7 @@ func (p *Procmail) Deliver(from string, to string, data []byte) (error, bool) {
 				permanent = status.ExitStatus() != 75
 			}
 		}
-		err = tr.Errorf("Procmail failed: %v - %q", err, string(output))
+		err = tr.Errorf("procmail failed: %v - %q", err, string(output))
 		return err, permanent
 	}
 
diff --git a/internal/dovecot/dovecot.go b/internal/dovecot/dovecot.go
index f6d2c13..ea6cf89 100644
--- a/internal/dovecot/dovecot.go
+++ b/internal/dovecot/dovecot.go
@@ -213,7 +213,7 @@ func expect(conn *textproto.Conn, prefix string) error {
 }
 
 func write(conn *textproto.Conn, msg string) error {
-	_, err := fmt.Fprintf(conn.W, msg)
+	_, err := conn.W.Write([]byte(msg))
 	if err != nil {
 		return err
 	}
diff --git a/internal/queue/queue_test.go b/internal/queue/queue_test.go
index 82e68f0..7b18bad 100644
--- a/internal/queue/queue_test.go
+++ b/internal/queue/queue_test.go
@@ -13,30 +13,12 @@ import (
 	"blitiri.com.ar/go/chasquid/internal/testlib"
 )
 
-// Test courier. Delivery is done by sending on a channel, so users have fine
-// grain control over the results.
-type ChanCourier struct {
-	requests chan deliverRequest
-	results  chan error
-}
-
 type deliverRequest struct {
 	from string
 	to   string
 	data []byte
 }
 
-func (cc *ChanCourier) Deliver(from string, to string, data []byte) (error, bool) {
-	cc.requests <- deliverRequest{from, to, data}
-	return <-cc.results, false
-}
-func newChanCourier() *ChanCourier {
-	return &ChanCourier{
-		requests: make(chan deliverRequest),
-		results:  make(chan error),
-	}
-}
-
 // Courier for test purposes. Never fails, and always remembers everything.
 type TestCourier struct {
 	wg       sync.WaitGroup
diff --git a/internal/sts/sts_test.go b/internal/sts/sts_test.go
index ddc71b9..7e9da5e 100644
--- a/internal/sts/sts_test.go
+++ b/internal/sts/sts_test.go
@@ -64,7 +64,6 @@ func testHTTPHandler(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 	fmt.Fprintln(w, policy)
-	return
 }
 
 func TestMain(m *testing.M) {