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
@@ -241,11 +241,11 @@ func (n Numeric) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
|
||||
func (n *Numeric) UnmarshalJSON(src []byte) error {
|
||||
if bytes.Compare(src, []byte(`null`)) == 0 {
|
||||
if bytes.Equal(src, []byte(`null`)) {
|
||||
*n = Numeric{}
|
||||
return nil
|
||||
}
|
||||
if bytes.Compare(src, []byte(`"NaN"`)) == 0 {
|
||||
if bytes.Equal(src, []byte(`"NaN"`)) {
|
||||
*n = Numeric{NaN: true, Valid: true}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user