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

Function renderValue

pkg/console/render.go:38–55  ·  view source on GitHub ↗

renderValue recursively renders a reflect.Value to the output builder

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

Source from the content-addressed store, hash-verified

36
37// renderValue recursively renders a reflect.Value to the output builder
38func renderValue(val reflect.Value, title string, output *strings.Builder, depth int) {
39 // Dereference pointers
40 for val.Kind() == reflect.Pointer {
41 if val.IsNil() {
42 return
43 }
44 val = val.Elem()
45 }
46
47 switch val.Kind() {
48 case reflect.Struct:
49 renderStruct(val, title, output, depth)
50 case reflect.Slice, reflect.Array:
51 renderSlice(val, title, output, depth)
52 case reflect.Map:
53 renderMap(val, title, output, depth)
54 }
55}
56
57// renderStruct renders a struct as markdown-style headers with key-value pairs
58func renderStruct(val reflect.Value, title string, output *strings.Builder, depth int) {

Callers 2

RenderStructFunction · 0.85
renderStructFieldFunction · 0.85

Calls 3

renderStructFunction · 0.85
renderSliceFunction · 0.85
renderMapFunction · 0.85

Tested by

no test coverage detected