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

Function applyCostFormat

pkg/console/render.go:621–640  ·  view source on GitHub ↗

applyCostFormat formats a value as currency with $ prefix.

(val reflect.Value, baseValue string)

Source from the content-addressed store, hash-verified

619
620// applyCostFormat formats a value as currency with $ prefix.
621func 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").
643func applyFilesizeFormat(val reflect.Value, baseValue string) string {

Callers 1

applyTagFormatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected