formatFieldValueWithTag formats a reflect.Value as a string for display with format tag support
(val reflect.Value, tag consoleTag)
| 550 | |
| 551 | // formatFieldValueWithTag formats a reflect.Value as a string for display with format tag support |
| 552 | func 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. |
| 575 | func applyTagFormat(val reflect.Value, format, baseValue string) string { |