structOnlyError returns an error appropriate for type when a non-scannable struct is expected but something else is given
(t reflect.Type)
| 869 | // structOnlyError returns an error appropriate for type when a non-scannable |
| 870 | // struct is expected but something else is given |
| 871 | func structOnlyError(t reflect.Type) error { |
| 872 | isStruct := t.Kind() == reflect.Struct |
| 873 | isScanner := reflect.PtrTo(t).Implements(_scannerInterface) |
| 874 | if !isStruct { |
| 875 | return fmt.Errorf("expected %s but got %s", reflect.Struct, t.Kind()) |
| 876 | } |
| 877 | if isScanner { |
| 878 | return fmt.Errorf("structscan expects a struct dest but the provided struct type %s implements scanner", t.Name()) |
| 879 | } |
| 880 | return fmt.Errorf("expected a struct, but struct %s has no exported fields", t.Name()) |
| 881 | } |
| 882 | |
| 883 | // scanAll scans all rows into a destination, which must be a slice of any |
| 884 | // type. It resets the slice length to zero before appending each element to |