tmp commit

This commit is contained in:
Liujian
2025-04-30 18:55:01 +08:00
parent 9c1b19a1c7
commit fef49eb32c
7 changed files with 230 additions and 156 deletions
+16 -1
View File
@@ -5,7 +5,7 @@ import (
"strconv"
)
func FormatCount(count int64) string {
func FormatCountInt64(count int64) string {
switch {
case count < 1000:
return strconv.FormatInt(count, 10)
@@ -20,6 +20,21 @@ func FormatCount(count int64) string {
}
}
func FormatCountFloat64(count float64) string {
switch {
case count < 1000:
return strconv.FormatFloat(count, 'f', -1, 64)
case count < 1000000:
return fmt.Sprintf("%.1fK", count/1000)
case count < 1000000000:
return fmt.Sprintf("%.1fM", count/1000000)
case count < 1000000000000:
return fmt.Sprintf("%.1fB", count/1000000000)
default:
return fmt.Sprintf("%.1fT", count/1000000000000)
}
}
func FormatTime(t int64) string {
if t < 1000 {
return strconv.FormatInt(t, 10) + "ms"