mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-14 20:41:15 +08:00
tmp commit
This commit is contained in:
+16
-1
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user