Chenged lowercase b meaning bits to uppercase B meaning Bytes (#481)

This commit is contained in:
leonardchinonso 2022-06-08 13:19:17 +01:00 committed by GitHub
parent 5278815cd0
commit 13529121f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,14 +21,14 @@ import "fmt"
func ByteCount(b uint64) string {
const unit = 1024
if b < unit {
return fmt.Sprintf("%db", b)
return fmt.Sprintf("%dB", b)
}
div, exp := uint64(unit), 0
for n := b / unit; n >= unit; n /= unit {
div *= unit
exp++
}
return fmt.Sprintf("%.1f%cb",
return fmt.Sprintf("%.1f%cB",
float64(b)/float64(div), "KMGTPE"[exp])
}