(a, b interface{})
| 48 | } |
| 49 | |
| 50 | func structCompare(a, b interface{}) (bool, string) { |
| 51 | va := reflect.ValueOf(a) |
| 52 | vb := reflect.ValueOf(b) |
| 53 | nFieldsA := va.NumField() |
| 54 | nFieldsB := vb.NumField() |
| 55 | |
| 56 | if nFieldsA != nFieldsB { |
| 57 | return true, "num_fields" |
| 58 | } |
| 59 | |
| 60 | for i := 0; i < nFieldsA; i++ { |
| 61 | fieldA := va.Type().Field(i) |
| 62 | fieldB := vb.Type().Field(i) |
| 63 | if fieldA.Name != fieldB.Name { |
| 64 | return true, fieldA.Name |
| 65 | } |
| 66 | |
| 67 | fieldName := strings.ToLower(fieldA.Name) |
| 68 | |
| 69 | fieldValueA := va.Field(i) |
| 70 | fieldValueB := vb.Field(i) |
| 71 | |
| 72 | if fieldValueA.Type() != fieldValueB.Type() { |
| 73 | return true, fmt.Sprintf("%s.type", fieldName) |
| 74 | } |
| 75 | |
| 76 | // same index, same name, same type, now let's check the value |
| 77 | if reflect.DeepEqual(fieldValueA.Interface(), fieldValueB.Interface()) == false { |
| 78 | return true, fieldName |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | return false, "" |
| 83 | } |
| 84 | |
| 85 | func contactCompare(a, b *whoisparser.Contact, prefix string) (bool, string) { |
| 86 | if a == nil && b != nil { |
no outgoing calls
no test coverage detected