getLen tries to get the length of an object. It returns (0, false) if impossible.
(x interface{})
| 780 | // getLen tries to get the length of an object. |
| 781 | // It returns (0, false) if impossible. |
| 782 | func getLen(x interface{}) (length int, ok bool) { |
| 783 | v := reflect.ValueOf(x) |
| 784 | defer func() { |
| 785 | ok = recover() == nil |
| 786 | }() |
| 787 | return v.Len(), true |
| 788 | } |
| 789 | |
| 790 | // Len asserts that the specified object has specific length. |
| 791 | // Len also fails if the object has a type that len() not accept. |
searching dependent graphs…