Use bytes.Equal rather than bytes.Compare ==/!= 0
As recommended by go-staticcheck, but also might be a bit more efficient for the compiler to implement, since we don't care about which slice of bytes is greater than the other one.
This commit is contained in:
committed by
Jack Christensen
parent
cd46cdd450
commit
0328d314ea
+2
-2
@@ -547,7 +547,7 @@ func TestConnQueryJSONIntoByteSlice(t *testing.T) {
|
||||
t.Errorf("Unexpected failure: %v (sql -> %v)", err, sql)
|
||||
}
|
||||
|
||||
if bytes.Compare(actual, expected) != 0 {
|
||||
if !bytes.Equal(actual, expected) {
|
||||
t.Errorf(`Expected "%v", got "%v" (sql -> %v)`, string(expected), string(actual), sql)
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ func TestConnExecInsertByteSliceIntoJSON(t *testing.T) {
|
||||
err = db.QueryRow(`select body from docs`).Scan(&actual)
|
||||
require.NoError(t, err)
|
||||
|
||||
if bytes.Compare(actual, expected) != 0 {
|
||||
if !bytes.Equal(actual, expected) {
|
||||
t.Errorf(`Expected "%v", got "%v"`, string(expected), string(actual))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user