Execute PLAN_FRONTEND.md
This commit is contained in:
26
cmd/frontend/format.go
Normal file
26
cmd/frontend/format.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// fmtCount formats a count with a space as the thousands separator.
|
||||
func fmtCount(n int64) string {
|
||||
s := fmt.Sprintf("%d", n)
|
||||
if len(s) <= 3 {
|
||||
return s
|
||||
}
|
||||
var b strings.Builder
|
||||
start := len(s) % 3
|
||||
if start > 0 {
|
||||
b.WriteString(s[:start])
|
||||
}
|
||||
for i := start; i < len(s); i += 3 {
|
||||
if i > 0 {
|
||||
b.WriteByte(' ')
|
||||
}
|
||||
b.WriteString(s[i : i+3])
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
Reference in New Issue
Block a user