Helper to extract field value from struct/map using reflection
(item any, key string)
| 66 | |
| 67 | // Helper to extract field value from struct/map using reflection |
| 68 | func getFieldValueWithReflection(item any, key string) any { |
| 69 | if item == nil { |
| 70 | return nil |
| 71 | } |
| 72 | |
| 73 | // Handle map[string]any |
| 74 | if m, ok := item.(map[string]any); ok { |
| 75 | return m[key] |
| 76 | } |
| 77 | |
| 78 | // Handle struct via reflection |
| 79 | v := reflect.ValueOf(item) |
| 80 | if v.Kind() == reflect.Ptr { |
| 81 | v = v.Elem() |
| 82 | } |
| 83 | if v.Kind() != reflect.Struct { |
| 84 | return nil |
| 85 | } |
| 86 | |
| 87 | field := v.FieldByName(key) |
| 88 | if !field.IsValid() { |
| 89 | return nil |
| 90 | } |
| 91 | return field.Interface() |
| 92 | } |
| 93 | |
| 94 | // Generic helper to extract field value using either AccessorFn or reflection |
| 95 | func getFieldValue[T any](row T, rowIdx int, col TableColumn[T]) any { |