formatThousands inserts thousands separators into a non-negative int.
(n int)
| 82 | |
| 83 | // formatThousands inserts thousands separators into a non-negative int. |
| 84 | func formatThousands(n int) string { |
| 85 | if n < 0 { |
| 86 | return "-" + formatThousands(-n) |
| 87 | } |
| 88 | if n < 1000 { |
| 89 | return fmt.Sprintf("%d", n) |
| 90 | } |
| 91 | return formatThousands(n/1000) + "," + fmt.Sprintf("%03d", n%1000) |
| 92 | } |
| 93 | |
| 94 | // runCommand handles a line that starts with "/". Returns true if handled, |
| 95 | // false if the line should fall through to the model as a normal message. |