mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-10-21 10:58:23 +00:00
Imported Upstream version 1.0.1
This commit is contained in:
1 parent
1ee35b841d
commit
4f12259bc0
5531 files changed
+1834599
-742844
No files matched your search
@@ -0,0 +1,22 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// HumanBytes converts bytes to human readable string
|
||||
func HumanBytes(i int64) (result string) {
|
||||
switch {
|
||||
case i > (512 * 1024 * 1024 * 1024):
|
||||
result = fmt.Sprintf("%.02f TiB", float64(i)/1024/1024/1024/1024)
|
||||
case i > (512 * 1024 * 1024):
|
||||
result = fmt.Sprintf("%.02f GiB", float64(i)/1024/1024/1024)
|
||||
case i > (512 * 1024):
|
||||
result = fmt.Sprintf("%.02f MiB", float64(i)/1024/1024)
|
||||
case i > 512:
|
||||
result = fmt.Sprintf("%.02f KiB", float64(i)/1024)
|
||||
default:
|
||||
result = fmt.Sprintf("%d B", i)
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in new issue
Block a user