convertMapStringInterface attempts to convert v to map[string]interface{}. Unlike v.(map[string]interface{}), this function works on named types that are convertible to map[string]interface{} as well.
(v interface{})
| 150 | // Unlike v.(map[string]interface{}), this function works on named types that |
| 151 | // are convertible to map[string]interface{} as well. |
| 152 | func convertMapStringInterface(v interface{}) (map[string]interface{}, bool) { |
| 153 | var m map[string]interface{} |
| 154 | mtype := reflect.TypeOf(m) |
| 155 | t := reflect.TypeOf(v) |
| 156 | if !t.ConvertibleTo(mtype) { |
| 157 | return nil, false |
| 158 | } |
| 159 | return reflect.ValueOf(v).Convert(mtype).Interface().(map[string]interface{}), true |
| 160 | |
| 161 | } |
| 162 | |
| 163 | func bindAnyArgs(names []string, arg interface{}, m *reflectx.Mapper) ([]interface{}, error) { |
| 164 | if maparg, ok := convertMapStringInterface(arg); ok { |
no outgoing calls
no test coverage detected