@@ 36,10 36,10 @@ func notFound(c echo.Context, msg string
return c.String(NOT_FOUND, msg)
}
-// Formatting byte size in human-readable format (SI - decimal)
+// Formatting byte size in human-readable format (IEC/binary)
// From https://yourbasic.org/golang/formatting-byte-size-to-human-readable-format/
-func ByteCountSI(b int64) string {
- const unit = 1000
+func ByteCountIEC(b int64) string {
+ const unit = 1024
if b < unit {
return fmt.Sprintf("%d B", b)
}
@@ 48,6 48,6 @@ func ByteCountSI(b int64) string {
div *= unit
exp++
}
- return fmt.Sprintf("%.1f %cB",
- float64(b)/float64(div), "kMGTPE"[exp])
+ return fmt.Sprintf("%.1f %ciB",
+ float64(b)/float64(div), "KMGTPE"[exp])
}