MCPcopy Create free account
hub / github.com/github/gh-aw / renderInlineEmbeddedFields

Function renderInlineEmbeddedFields

pkg/console/render.go:79–96  ·  view source on GitHub ↗

renderInlineEmbeddedFields renders the fields of an anonymous embedded struct directly into the parent struct output, flattening the hierarchy.

(val reflect.Value, maxFieldLen int, output *strings.Builder, depth int)

Source from the content-addressed store, hash-verified

77// renderInlineEmbeddedFields renders the fields of an anonymous embedded struct
78// directly into the parent struct output, flattening the hierarchy.
79func renderInlineEmbeddedFields(val reflect.Value, maxFieldLen int, output *strings.Builder, depth int) {
80 walkInlineFields(val, func(field reflect.Value, fieldType reflect.StructField) {
81 tag := parseConsoleTag(fieldType.Tag.Get("console"))
82 if tag.skip {
83 return
84 }
85 if tag.omitempty && isZeroValue(field) {
86 return
87 }
88
89 fieldName := fieldType.Name
90 if tag.header != "" {
91 fieldName = tag.header
92 }
93
94 renderStructField(field, fieldName, tag, maxFieldLen, output, depth)
95 })
96}
97
98// computeMaxFieldLen computes the longest visible field name for alignment,
99// recursing into anonymous embedded structs to include their fields.

Callers 1

renderStructFunction · 0.85

Calls 5

walkInlineFieldsFunction · 0.85
parseConsoleTagFunction · 0.85
isZeroValueFunction · 0.85
renderStructFieldFunction · 0.85
GetMethod · 0.45

Tested by

no test coverage detected