Equals returns whether two fields are equal. For non-primitive types such as errors, marshalers, or reflect types, it uses reflect.DeepEqual.
(other Field)
| 188 | // Equals returns whether two fields are equal. For non-primitive types such as |
| 189 | // errors, marshalers, or reflect types, it uses reflect.DeepEqual. |
| 190 | func (f Field) Equals(other Field) bool { |
| 191 | if f.Type != other.Type { |
| 192 | return false |
| 193 | } |
| 194 | if f.Key != other.Key { |
| 195 | return false |
| 196 | } |
| 197 | |
| 198 | switch f.Type { |
| 199 | case BinaryType, ByteStringType: |
| 200 | return bytes.Equal(f.Interface.([]byte), other.Interface.([]byte)) |
| 201 | case ArrayMarshalerType, ObjectMarshalerType, ErrorType, ReflectType: |
| 202 | return reflect.DeepEqual(f.Interface, other.Interface) |
| 203 | default: |
| 204 | return f == other |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | func addFields(enc ObjectEncoder, fields []Field) { |
| 209 | for i := range fields { |
no outgoing calls