samePointers checks if two generic interface objects are pointers of the same type pointing to the same object. It returns two values: same indicating if they are the same type and point to the same object, and ok indicating that both inputs are pointers.
(first, second interface{})
| 582 | // they are the same type and point to the same object, and ok indicating that |
| 583 | // both inputs are pointers. |
| 584 | func samePointers(first, second interface{}) (same bool, ok bool) { |
| 585 | firstPtr, secondPtr := reflect.ValueOf(first), reflect.ValueOf(second) |
| 586 | if firstPtr.Kind() != reflect.Ptr || secondPtr.Kind() != reflect.Ptr { |
| 587 | return false, false // not both are pointers |
| 588 | } |
| 589 | |
| 590 | firstType, secondType := reflect.TypeOf(first), reflect.TypeOf(second) |
| 591 | if firstType != secondType { |
| 592 | return false, true // both are pointers, but of different types |
| 593 | } |
| 594 | |
| 595 | // compare pointer addresses |
| 596 | return first == second, true |
| 597 | } |
| 598 | |
| 599 | // formatUnequalValues takes two values of arbitrary types and returns string |
| 600 | // representations appropriate to be presented to the user. |
no outgoing calls
searching dependent graphs…