MapScan scans a single Row into the dest map[string]interface{}. Use this to get results for SQL that might not be under your control (for instance, if you're building an interface for an SQL server that executes SQL from input). Please do not use this as a primary interface! This will modify the m
(r ColScanner, dest map[string]interface{})
| 835 | // care. Columns which occur more than once in the result will overwrite |
| 836 | // each other! |
| 837 | func MapScan(r ColScanner, dest map[string]interface{}) error { |
| 838 | // ignore r.started, since we needn't use reflect for anything. |
| 839 | columns, err := r.Columns() |
| 840 | if err != nil { |
| 841 | return err |
| 842 | } |
| 843 | |
| 844 | values := make([]interface{}, len(columns)) |
| 845 | for i := range values { |
| 846 | values[i] = new(interface{}) |
| 847 | } |
| 848 | |
| 849 | err = r.Scan(values...) |
| 850 | if err != nil { |
| 851 | return err |
| 852 | } |
| 853 | |
| 854 | for i, column := range columns { |
| 855 | dest[column] = *(values[i].(*interface{})) |
| 856 | } |
| 857 | |
| 858 | return r.Err() |
| 859 | } |
| 860 | |
| 861 | type rowsi interface { |
| 862 | Close() error |