MCPcopy
hub / github.com/redis/go-redis / newStructSpec

Function newStructSpec

internal/hscan/structmap.go:44–72  ·  view source on GitHub ↗
(t reflect.Type, fieldTag string)

Source from the content-addressed store, hash-verified

42}
43
44func newStructSpec(t reflect.Type, fieldTag string) *structSpec {
45 numField := t.NumField()
46 out := &structSpec{
47 m: make(map[string]*structField, numField),
48 }
49
50 for i := 0; i < numField; i++ {
51 f := t.Field(i)
52
53 tag := f.Tag.Get(fieldTag)
54 if tag == "" || tag == "-" {
55 continue
56 }
57
58 tag = strings.Split(tag, ",")[0]
59 if tag == "" {
60 continue
61 }
62
63 // Use the built-in decoder.
64 kind := f.Type.Kind()
65 if kind == reflect.Pointer {
66 kind = f.Type.Elem().Kind()
67 }
68 out.set(tag, &structField{index: i, fn: decoders[kind]})
69 }
70
71 return out
72}
73
74//------------------------------------------------------------------------------
75

Callers 1

getMethod · 0.85

Calls 2

setMethod · 0.95
GetMethod · 0.65

Tested by

no test coverage detected