mirror of
https://github.com/walles/moar.git
synced 2024-09-11 12:15:43 +03:00
Both the numbers in the left column of the file display, and the line numbers shown in the page footer. Fixes #6.
22 lines
405 B
Go
22 lines
405 B
Go
package m
|
|
|
|
import "fmt"
|
|
|
|
// Formats a number into a string with _ between each three-group of digits
|
|
func formatNumber(number uint) string {
|
|
result := ""
|
|
|
|
chars := []rune(fmt.Sprint(number))
|
|
addCount := 0
|
|
for i := len(chars) - 1; i >= 0; i-- {
|
|
char := chars[i]
|
|
if len(result) > 0 && addCount%3 == 0 {
|
|
result = "_" + result
|
|
}
|
|
result = string(char) + result
|
|
addCount++
|
|
}
|
|
|
|
return result
|
|
}
|