applyCostFormat formats a value as currency with $ prefix.
(val reflect.Value, baseValue string)
| 619 | |
| 620 | // applyCostFormat formats a value as currency with $ prefix. |
| 621 | func applyCostFormat(val reflect.Value, baseValue string) string { |
| 622 | if val.CanInterface() { |
| 623 | switch v := val.Interface().(type) { |
| 624 | case float64: |
| 625 | if v > 0 { |
| 626 | return fmt.Sprintf("$%.3f", v) |
| 627 | } |
| 628 | case float32: |
| 629 | if v > 0 { |
| 630 | return fmt.Sprintf("$%.3f", v) |
| 631 | } |
| 632 | } |
| 633 | } |
| 634 | if val.Kind() == reflect.Float64 || val.Kind() == reflect.Float32 { |
| 635 | if val.Float() > 0 { |
| 636 | return fmt.Sprintf("$%.3f", val.Float()) |
| 637 | } |
| 638 | } |
| 639 | return baseValue |
| 640 | } |
| 641 | |
| 642 | // applyFilesizeFormat formats a value as a human-readable file size (e.g., "1.2 MB"). |
| 643 | func applyFilesizeFormat(val reflect.Value, baseValue string) string { |