diff --git a/client.go b/client.go index e969ff9..2c62612 100644 --- a/client.go +++ b/client.go @@ -275,9 +275,7 @@ type StopErr struct { } func (e StopErr) Error() string { - return fmt.Sprintf("error while stopping due to %s: %s", - sprintErr(e.Cause), sprintErr(e.Err), - ) + return fmt.Sprintf("error while stopping due to %s: %s", sprintErr(e.Cause), sprintErr(e.Err)) } // CloseErr indicates client close failure. @@ -294,9 +292,7 @@ func sprintErr(err error) string { } func (c CloseErr) Error() string { - return fmt.Sprintf("failed to close: %s (connection), %s (agent)", - sprintErr(c.ConnectionErr), sprintErr(c.AgentErr), - ) + return fmt.Sprintf("failed to close: %s (connection), %s (agent)", sprintErr(c.ConnectionErr), sprintErr(c.AgentErr)) } func (c *Client) readUntilClosed() { diff --git a/integrity.go b/integrity.go index 3bda1cd..18aaa4a 100644 --- a/integrity.go +++ b/integrity.go @@ -16,14 +16,7 @@ const credentialsSep = ":" // NewLongTermIntegrity returns new MessageIntegrity with key for long-term // credentials. Password, username, and realm must be SASL-prepared. func NewLongTermIntegrity(username, realm, password string) MessageIntegrity { - k := strings.Join( - []string{ - username, - realm, - password, - }, - credentialsSep, - ) + k := strings.Join([]string{username, realm, password}, credentialsSep) // #nosec h := md5.New() fmt.Fprint(h, k) diff --git a/message.go b/message.go index 75b21a6..ce83508 100644 --- a/message.go +++ b/message.go @@ -93,12 +93,8 @@ func (m *Message) NewTransactionID() error { } func (m *Message) String() string { - return fmt.Sprintf("%s l=%d attrs=%d id=%s", - m.Type, - m.Length, - len(m.Attributes), - base64.StdEncoding.EncodeToString(m.TransactionID[:]), - ) + tID := base64.StdEncoding.EncodeToString(m.TransactionID[:]) + return fmt.Sprintf("%s l=%d attrs=%d id=%s", m.Type, m.Length, len(m.Attributes), tID) } // Reset resets Message, attributes and underlying buffer length. @@ -336,17 +332,11 @@ func (m *Message) Decode() error { fullSize = messageHeaderSize + size // len(m.Raw) ) if cookie != magicCookie { - msg := fmt.Sprintf( - "%x is invalid magic cookie (should be %x)", - cookie, magicCookie, - ) + msg := fmt.Sprintf("%x is invalid magic cookie (should be %x)", cookie, magicCookie) return newDecodeErr("message", "cookie", msg) } if len(buf) < fullSize { - msg := fmt.Sprintf( - "buffer length %d is less than %d (expected message size)", - len(buf), fullSize, - ) + msg := fmt.Sprintf("buffer length %d is less than %d (expected message size)", len(buf), fullSize) return newAttrDecodeErr("message", msg) } // saving header data @@ -362,10 +352,7 @@ func (m *Message) Decode() error { for offset < size { // checking that we have enough bytes to read header if len(b) < attributeHeaderSize { - msg := fmt.Sprintf( - "buffer length %d is less than %d (expected header size)", - len(b), attributeHeaderSize, - ) + msg := fmt.Sprintf("buffer length %d is less than %d (expected header size)", len(b), attributeHeaderSize) return newAttrDecodeErr("header", msg) } var ( @@ -379,10 +366,7 @@ func (m *Message) Decode() error { b = b[attributeHeaderSize:] // slicing again to simplify value read offset += attributeHeaderSize if len(b) < aBuffL { // checking size - msg := fmt.Sprintf( - "buffer length %d is less than %d (expected value size for %s)", - len(b), aBuffL, a.Type, - ) + msg := fmt.Sprintf("buffer length %d is less than %d (expected value size for %s)", len(b), aBuffL, a.Type) return newAttrDecodeErr("value", msg) } a.Value = b[:aL] diff --git a/uattrs.go b/uattrs.go index 25a9854..238d32d 100644 --- a/uattrs.go +++ b/uattrs.go @@ -56,9 +56,7 @@ func (a *UnknownAttributes) GetFrom(m *Message) error { first := 0 for first < len(v) { last := first + attrTypeSize - *a = append(*a, - AttrType(bin.Uint16(v[first:last])), - ) + *a = append(*a, AttrType(bin.Uint16(v[first:last]))) first = last } return nil