git » chasquid » commit 25ebc4f

Avoid unnecessary calls to fmt.Sprintf

author Alberto Bertogli
2020-04-13 12:58:31 UTC
committer Alberto Bertogli
2020-04-14 11:01:01 UTC
parent d6b512166b6ecc23ea7c6e2831f69efa23936e82

Avoid unnecessary calls to fmt.Sprintf

The linter caught some unnecessary calls to fmt.Sprintf. This patch
removes them.

There are no functional changes.

internal/queue/queue.go +2 -2
internal/queue/queue_test.go +2 -2
internal/smtpsrv/conn.go +1 -1

diff --git a/internal/queue/queue.go b/internal/queue/queue.go
index 802a494..1a90fe8 100644
--- a/internal/queue/queue.go
+++ b/internal/queue/queue.go
@@ -232,7 +232,7 @@ func (q *Queue) Remove(id string) {
 func (q *Queue) DumpString() string {
 	q.mu.RLock()
 	defer q.mu.RUnlock()
-	s := fmt.Sprintf("# Queue status\n\n")
+	s := "# Queue status\n\n"
 	s += fmt.Sprintf("date: %v\n", time.Now())
 	s += fmt.Sprintf("length: %d\n\n", len(q.q))
 
@@ -248,7 +248,7 @@ func (q *Queue) DumpString() string {
 			s += fmt.Sprintf("  last failure: %q\n", rcpt.LastFailureMessage)
 		}
 		item.Unlock()
-		s += fmt.Sprintf("\n")
+		s += "\n"
 	}
 
 	return s
diff --git a/internal/queue/queue_test.go b/internal/queue/queue_test.go
index 3b9ecbf..cb9167b 100644
--- a/internal/queue/queue_test.go
+++ b/internal/queue/queue_test.go
@@ -74,7 +74,7 @@ func TestDSNOnTimeout(t *testing.T) {
 	item := &Item{
 		Message: Message{
 			ID:   <-newID,
-			From: fmt.Sprintf("from@loco"),
+			From: "from@loco",
 			Rcpt: []*Recipient{
 				mkR("to@to", Recipient_EMAIL, Recipient_PENDING, "err", "to@to")},
 			Data: []byte("data"),
@@ -245,7 +245,7 @@ func TestSerialization(t *testing.T) {
 	item := &Item{
 		Message: Message{
 			ID:   <-newID,
-			From: fmt.Sprintf("from@loco"),
+			From: "from@loco",
 			Rcpt: []*Recipient{
 				mkR("to@to", Recipient_EMAIL, Recipient_PENDING, "err", "to@to")},
 			Data: []byte("data"),
diff --git a/internal/smtpsrv/conn.go b/internal/smtpsrv/conn.go
index 7a2491c..611f4b9 100644
--- a/internal/smtpsrv/conn.go
+++ b/internal/smtpsrv/conn.go
@@ -606,7 +606,7 @@ func (c *Conn) DATA(params string) (code int, msg string) {
 			// the user keeps sending as commands, and that's a security
 			// issue.
 			readUntilDot(c.reader)
-			return 552, fmt.Sprintf("5.3.4 Message too big")
+			return 552, "5.3.4 Message too big"
 		}
 		return 554, fmt.Sprintf("5.4.0 Error reading DATA: %v", err)
 	}