38e35acb4e
Release 3X-UI for Docker / build (push) Has been cancelled
Release 3X-UI / build (386) (push) Has been cancelled
Release 3X-UI / build (amd64) (push) Has been cancelled
Release 3X-UI / build (arm64) (push) Has been cancelled
Release 3X-UI / build (armv5) (push) Has been cancelled
Release 3X-UI / build (armv6) (push) Has been cancelled
Release 3X-UI / build (armv7) (push) Has been cancelled
Release 3X-UI / build (s390x) (push) Has been cancelled
18 lines
321 B
Go
18 lines
321 B
Go
package common
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
func FormatTraffic(trafficBytes int64) string {
|
|
units := []string{"B", "KB", "MB", "GB", "TB", "PB"}
|
|
unitIndex := 0
|
|
size := float64(trafficBytes)
|
|
|
|
for size >= 1024 && unitIndex < len(units)-1 {
|
|
size /= 1024
|
|
unitIndex++
|
|
}
|
|
return fmt.Sprintf("%.2f%s", size, units[unitIndex])
|
|
}
|