map[reflect.Type]*bindStructMeta
(typ reflect.Type)
| 182 | var bindStructCache sync.Map // map[reflect.Type]*bindStructMeta |
| 183 | |
| 184 | func bindMetaFor(typ reflect.Type) *bindStructMeta { |
| 185 | if cached, ok := bindStructCache.Load(typ); ok { |
| 186 | return cached.(*bindStructMeta) |
| 187 | } |
| 188 | n := typ.NumField() |
| 189 | meta := &bindStructMeta{fields: make([]bindFieldMeta, n)} |
| 190 | for i := 0; i < n; i++ { |
| 191 | f := typ.Field(i) |
| 192 | meta.fields[i] = bindFieldMeta{ |
| 193 | index: i, |
| 194 | anonymous: f.Anonymous, |
| 195 | fieldKind: f.Type.Kind(), |
| 196 | formatTag: f.Tag.Get("format"), |
| 197 | param: f.Tag.Get("param"), |
| 198 | query: f.Tag.Get("query"), |
| 199 | form: f.Tag.Get("form"), |
| 200 | header: f.Tag.Get("header"), |
| 201 | } |
| 202 | } |
| 203 | bindStructCache.Store(typ, meta) |
| 204 | return meta |
| 205 | } |
| 206 | |
| 207 | // bindData will bind data ONLY fields in destination struct that have EXPLICIT tag |
| 208 | func bindData(destination any, data map[string][]string, tag string, dataFiles map[string][]*multipart.FileHeader) error { |