formatThousands inserts thousands separators into a non-negative int. Mirrors the helper in commands.go; lives here too to avoid a UI → main dependency.
(n int)
| 1189 | // Mirrors the helper in commands.go; lives here too to avoid a UI → main |
| 1190 | // dependency. |
| 1191 | func formatThousands(n int) string { |
| 1192 | if n < 0 { |
| 1193 | return "-" + formatThousands(-n) |
| 1194 | } |
| 1195 | if n < 1000 { |
| 1196 | return fmt.Sprintf("%d", n) |
| 1197 | } |
| 1198 | return formatThousands(n/1000) + "," + fmt.Sprintf("%03d", n%1000) |
| 1199 | } |