formatUsageQty formats a usage quantity for display (e.g. 1000000 → "1,000,000").
(qty float64)
| 773 | |
| 774 | // formatUsageQty formats a usage quantity for display (e.g. 1000000 → "1,000,000"). |
| 775 | func formatUsageQty(qty float64) string { |
| 776 | s := strconv.FormatFloat(qty, 'f', 0, 64) |
| 777 | // Insert thousand separators. |
| 778 | n := len(s) |
| 779 | if n <= 3 { |
| 780 | return s |
| 781 | } |
| 782 | var out []byte |
| 783 | for i, c := range s { |
| 784 | if i > 0 && (n-i)%3 == 0 { |
| 785 | out = append(out, ',') |
| 786 | } |
| 787 | out = append(out, byte(c)) |
| 788 | } |
| 789 | return string(out) |
| 790 | } |
no outgoing calls
no test coverage detected