diff --git a/acme/acme_test.go b/acme/acme_test.go index a3118f4..47a081b 100644 --- a/acme/acme_test.go +++ b/acme/acme_test.go @@ -734,7 +734,7 @@ func TestTLSALPN01ChallengeCert(t *testing.T) { if !acmeExts[0].Critical { t.Errorf("acmeExt.Critical = %v; want true", acmeExts[0].Critical) } - if bytes.Compare(acmeExts[0].Value, extValue) != 0 { + if !bytes.Equal(acmeExts[0].Value, extValue) { t.Errorf("acmeExt.Value = %v; want %v", acmeExts[0].Value, extValue) } diff --git a/acme/types.go b/acme/types.go index 65d69b2..4df7e6d 100644 --- a/acme/types.go +++ b/acme/types.go @@ -114,14 +114,15 @@ type Error struct { } func (e *Error) Error() string { - str := fmt.Sprintf("%d %s: %s", e.StatusCode, e.ProblemType, e.Detail) + var sb strings.Builder + fmt.Fprintf(&sb, "%d %s: %s", e.StatusCode, e.ProblemType, e.Detail) if len(e.Subproblems) > 0 { - str += fmt.Sprintf("; subproblems:") + sb.WriteString("; subproblems:") for _, sp := range e.Subproblems { - str += fmt.Sprintf("\n\t%s", sp) + fmt.Fprintf(&sb, "\n\t%s", sp) } } - return str + return sb.String() } // AuthorizationError indicates that an authorization for an identifier diff --git a/ocsp/ocsp.go b/ocsp/ocsp.go index c6bc424..23c39e7 100644 --- a/ocsp/ocsp.go +++ b/ocsp/ocsp.go @@ -322,7 +322,7 @@ type Request struct { func (req *Request) Marshal() ([]byte, error) { hashAlg := getOIDFromHashAlgorithm(req.HashAlgorithm) if hashAlg == nil { - return nil, errors.New("Unknown hash algorithm") + return nil, errors.New("unknown hash algorithm") } return asn1.Marshal(ocspRequest{ TBSRequest: tbsRequest{ diff --git a/ocsp/ocsp_test.go b/ocsp/ocsp_test.go index abdea02..d6a86b1 100644 --- a/ocsp/ocsp_test.go +++ b/ocsp/ocsp_test.go @@ -195,7 +195,7 @@ func TestOCSPRequest(t *testing.T) { t.Fatal(err) } - if bytes.Compare(expectedBytes, marshaledRequest) != 0 { + if !bytes.Equal(expectedBytes, marshaledRequest) { t.Errorf( "Marshaled request doesn't match expected: wanted %x, got %x", expectedBytes, diff --git a/ssh/agent/keyring.go b/ssh/agent/keyring.go index a9e29b6..a4f4c11 100644 --- a/ssh/agent/keyring.go +++ b/ssh/agent/keyring.go @@ -104,7 +104,7 @@ func (r *keyring) Unlock(passphrase []byte) error { if !r.locked { return errors.New("agent: not locked") } - if 1 != subtle.ConstantTimeCompare(passphrase, r.passphrase) { + if subtle.ConstantTimeCompare(passphrase, r.passphrase) != 1 { return fmt.Errorf("agent: incorrect passphrase") } diff --git a/ssh/buffer_test.go b/ssh/buffer_test.go index d5781cb..0f20904 100644 --- a/ssh/buffer_test.go +++ b/ssh/buffer_test.go @@ -38,7 +38,7 @@ func TestBufferReadwrite(t *testing.T) { b.write(alphabet[5:15]) r, _ = b.Read(make([]byte, 10)) r2, _ := b.Read(make([]byte, 10)) - if r != 10 || r2 != 5 || 15 != r+r2 { + if r != 10 || r2 != 5 || r+r2 != 15 { t.Fatal("Expected written == read == 15") } } diff --git a/ssh/handshake_test.go b/ssh/handshake_test.go index 1322db4..baf7a4f 100644 --- a/ssh/handshake_test.go +++ b/ssh/handshake_test.go @@ -195,7 +195,7 @@ func TestHandshakeBasic(t *testing.T) { } want := []byte{msgRequestSuccess, byte(i)} - if bytes.Compare(p, want) != 0 { + if !bytes.Equal(p, want) { t.Errorf("message %d: got %v, want %v", i, p, want) } } diff --git a/ssh/keys_test.go b/ssh/keys_test.go index 2fb88e3..12316dc 100644 --- a/ssh/keys_test.go +++ b/ssh/keys_test.go @@ -1014,7 +1014,7 @@ func TestKnownHostsParsing(t *testing.T) { input := test.input if strings.Contains(input, rsaKeyToken) { expectedKey = rsaPub - input = strings.Replace(test.input, rsaKeyToken, rsaPubSerialized, -1) + input = strings.ReplaceAll(test.input, rsaKeyToken, rsaPubSerialized) } marker, hosts, pubKey, comment, rest, err := ParseKnownHosts([]byte(input)) diff --git a/ssh/session_test.go b/ssh/session_test.go index a6815bc..3c6bf13 100644 --- a/ssh/session_test.go +++ b/ssh/session_test.go @@ -745,7 +745,7 @@ func TestSessionID(t *testing.T) { s := <-serverID c := <-clientID - if bytes.Compare(s, c) != 0 { + if !bytes.Equal(s, c) { t.Errorf("server session ID (%x) != client session ID (%x)", s, c) } else if len(s) == 0 { t.Errorf("client and server SessionID were empty.")