MCPcopy Create free account
hub / github.com/ZeppelinMC/Zeppelin / structMap

Function structMap

properties/decode.go:97–127  ·  view source on GitHub ↗
(val reflect.Value)

Source from the content-addressed store, hash-verified

95}
96
97func structMap(val reflect.Value) map[string]reflect.Value {
98 var sm = make(map[string]reflect.Value, val.NumField())
99
100 vt := val.Type()
101 for i := 0; i < val.NumField(); i++ {
102 ft := vt.Field(i)
103 fv := val.Field(i)
104
105 if !ft.IsExported() {
106 continue
107 }
108 name := ft.Name
109 propName, ok := ft.Tag.Lookup("properties")
110 if ok {
111 if propName == "-" {
112 continue
113 }
114 name = propName
115 if i := strings.Index(name, ",omitempty"); i != -1 {
116 name = name[:i]
117 }
118 }
119 if name == "" {
120 name = ft.Name
121 }
122
123 sm[name] = fv
124 }
125
126 return sm
127}

Callers 1

UnmarshalFunction · 0.85

Calls 2

LookupMethod · 0.80
TypeMethod · 0.45

Tested by

no test coverage detected