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

Function NewMapperFunc

reflectx/reflect.go:94–100  ·  view source on GitHub ↗

NewMapperFunc returns a new mapper which optionally obeys a field tag and a struct field name mapper func given by f. Tags will take precedence, but for any other field, the mapped name will be f(field.Name)

(tagName string, f func(string) string)

Source from the content-addressed store, hash-verified

92// a struct field name mapper func given by f. Tags will take precedence, but
93// for any other field, the mapped name will be f(field.Name)
94func NewMapperFunc(tagName string, f func(string) string) *Mapper {
95 return &Mapper{
96 cache: make(map[reflect.Type]*StructMap),
97 tagName: tagName,
98 mapFunc: f,
99 }
100}
101
102// TypeMap returns a mapping of field strings to int slices representing
103// the traversal down the struct to reach the field.

Callers 12

mapperFunction · 0.92
MapperFuncMethod · 0.92
TestNamedQueryFunction · 0.92
TestBindNamedMapperFunction · 0.92
TestNamedQueryContextFunction · 0.92
TestBasicFunction · 0.85
TestBasicEmbeddedFunction · 0.85
TestRecursiveStructFunction · 0.85
TestFieldMapFunction · 0.85
TestMappingFunction · 0.85
TestGetByTraversalFunction · 0.85
TestMapperMethodsByNameFunction · 0.85

Calls

no outgoing calls

Tested by 10

TestNamedQueryFunction · 0.74
TestBindNamedMapperFunction · 0.74
TestNamedQueryContextFunction · 0.74
TestBasicFunction · 0.68
TestBasicEmbeddedFunction · 0.68
TestRecursiveStructFunction · 0.68
TestFieldMapFunction · 0.68
TestMappingFunction · 0.68
TestGetByTraversalFunction · 0.68
TestMapperMethodsByNameFunction · 0.68