This commit is contained in:
milarin 2023-01-15 14:25:37 +01:00
parent 481168e4e1
commit 26a0590e06

View File

@ -8,13 +8,14 @@ import (
func FormatBytes[T gmath.Integer](bytes T) string { func FormatBytes[T gmath.Integer](bytes T) string {
value := float64(bytes) value := float64(bytes)
if value/1000000000000 >= 1000000000000 {
if value >= 1000000000000 {
return fmt.Sprintf("%.02fT", value/1000000000000) return fmt.Sprintf("%.02fT", value/1000000000000)
} else if value/1000000000 >= 1000000000 { } else if value >= 1000000000 {
return fmt.Sprintf("%.02fG", value/1000000000) return fmt.Sprintf("%.02fG", value/1000000000)
} else if value/1000000 >= 1000000 { } else if value >= 1000000 {
return fmt.Sprintf("%.02fM", value/1000000) return fmt.Sprintf("%.02fM", value/1000000)
} else if value/1000 >= 1000 { } else if value >= 1000 {
return fmt.Sprintf("%.02fK", value/1000) return fmt.Sprintf("%.02fK", value/1000)
} else { } else {
return fmt.Sprintf("%.02fB", value) return fmt.Sprintf("%.02fB", value)