MCPcopy Create free account
hub / github.com/apache/fory / parseFieldSpec

Function parseFieldSpec

go/fory/field_spec.go:429–458  ·  view source on GitHub ↗
(field reflect.StructField, xlang bool, trackRef bool)

Source from the content-addressed store, hash-verified

427}
428
429func parseFieldSpec(field reflect.StructField, xlang bool, trackRef bool) (FieldSpec, error) {
430 parsed, err := parseFieldTag(field)
431 if err != nil {
432 return FieldSpec{}, err
433 }
434 spec := FieldSpec{
435 Name: SnakeCase(field.Name),
436 GoType: field.Type,
437 TagID: TagIDUseFieldName,
438 Ignore: parsed.ignore,
439 HasTag: parsed.hasTag,
440 RawTag: parsed.rawTag,
441 Nullable: parsed.nullable,
442 NullableSet: parsed.nullableSet,
443 Ref: parsed.ref,
444 RefSet: parsed.refSet,
445 }
446 if parsed.idSet {
447 spec.TagID = parsed.tagID
448 }
449 if parsed.ignore {
450 return spec, nil
451 }
452 typeSpec, err := resolveFieldTypeSpec(field, parsed, xlang, trackRef)
453 if err != nil {
454 return FieldSpec{}, err
455 }
456 spec.Type = typeSpec
457 return spec, nil
458}
459
460func parseFieldTag(field reflect.StructField) (parsedFieldTag, error) {
461 parsed := parsedFieldTag{tagID: TagIDUseFieldName}

Callers 5

mustParseFieldSpecFunction · 0.85
initFieldsMethod · 0.85
initFieldsFromTypeDefMethod · 0.85
buildFieldDefsFunction · 0.85

Calls 3

parseFieldTagFunction · 0.85
SnakeCaseFunction · 0.85
resolveFieldTypeSpecFunction · 0.85

Tested by 2

mustParseFieldSpecFunction · 0.68