MCPcopy
hub / github.com/jmoiron/sqlx / convertMapStringInterface

Function convertMapStringInterface

named.go:152–161  ·  view source on GitHub ↗

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{})

Source from the content-addressed store, hash-verified

150// Unlike v.(map[string]interface{}), this function works on named types that
151// are convertible to map[string]interface{} as well.
152func 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
163func bindAnyArgs(names []string, arg interface{}, m *reflectx.Mapper) ([]interface{}, error) {
164 if maparg, ok := convertMapStringInterface(arg); ok {

Callers 2

bindAnyArgsFunction · 0.85
bindNamedMapperFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected