MCPcopy Create free account
hub / github.com/buke/quickjs-go / parseFieldTag

Function parseFieldTag

marshal.go:44–61  ·  view source on GitHub ↗

parseFieldTag parses struct field tags, handling both "js" and "json" tags This function provides unified tag parsing logic for both marshal and class reflection

(field reflect.StructField)

Source from the content-addressed store, hash-verified

42// parseFieldTag parses struct field tags, handling both "js" and "json" tags
43// This function provides unified tag parsing logic for both marshal and class reflection
44func parseFieldTag(field reflect.StructField) FieldTagInfo {
45 // Check "js" tag first (higher priority)
46 if tag := field.Tag.Get("js"); tag != "" {
47 return parseTagString(tag, field.Name)
48 }
49
50 // Fallback to "json" tag
51 if tag := field.Tag.Get("json"); tag != "" {
52 return parseTagString(tag, field.Name)
53 }
54
55 // No tag found, use camelCase field name
56 return FieldTagInfo{
57 Name: fieldNameToCamelCase(field.Name),
58 Skip: false,
59 OmitEmpty: false,
60 }
61}
62
63// parseTagString parses tag string in format "name,option1,option2"
64func parseTagString(tag, fieldName string) FieldTagInfo {

Callers 4

marshalStructMethod · 0.85
unmarshalStructMethod · 0.85
initializeFromObjectArgsFunction · 0.85
addReflectionAccessorsFunction · 0.85

Calls 3

parseTagStringFunction · 0.85
fieldNameToCamelCaseFunction · 0.85
GetMethod · 0.80

Tested by

no test coverage detected