MCPcopy
hub / github.com/uber-go/zap / Equals

Method Equals

zapcore/field.go:190–206  ·  view source on GitHub ↗

Equals returns whether two fields are equal. For non-primitive types such as errors, marshalers, or reflect types, it uses reflect.DeepEqual.

(other Field)

Source from the content-addressed store, hash-verified

188// Equals returns whether two fields are equal. For non-primitive types such as
189// errors, marshalers, or reflect types, it uses reflect.DeepEqual.
190func (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
208func addFields(enc ObjectEncoder, fields []Field) {
209 for i := range fields {

Callers 3

TestFieldsFunction · 0.95
TestEqualsFunction · 0.80
FilterFieldMethod · 0.80

Calls

no outgoing calls

Tested by 2

TestFieldsFunction · 0.76
TestEqualsFunction · 0.64