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

Function formatFieldValueWithTag

pkg/console/render.go:552–572  ·  view source on GitHub ↗

formatFieldValueWithTag formats a reflect.Value as a string for display with format tag support

(val reflect.Value, tag consoleTag)

Source from the content-addressed store, hash-verified

550
551// formatFieldValueWithTag formats a reflect.Value as a string for display with format tag support
552func formatFieldValueWithTag(val reflect.Value, tag consoleTag) string {
553 // Get the base formatted value
554 baseValue := formatFieldValue(val)
555
556 // Check if value is zero/empty and apply default if specified
557 if tag.defaultVal != "" && isZeroValue(val) {
558 baseValue = tag.defaultVal
559 }
560
561 // Apply format based on tag
562 if tag.format != "" && baseValue != "-" {
563 baseValue = applyTagFormat(val, tag.format, baseValue)
564 }
565
566 // Apply maxlen truncation if specified
567 if tag.maxLen > 0 {
568 baseValue = stringutil.Truncate(baseValue, tag.maxLen)
569 }
570
571 return baseValue
572}
573
574// applyTagFormat applies a named format (number, cost, filesize) to baseValue.
575func applyTagFormat(val reflect.Value, format, baseValue string) string {

Calls 4

TruncateFunction · 0.92
formatFieldValueFunction · 0.85
isZeroValueFunction · 0.85
applyTagFormatFunction · 0.85