forked from toolshed/abra
refactor: improved logging on pruning
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package formatter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
@ -70,3 +71,21 @@ func StripTagMeta(image string) string {
|
||||
|
||||
return image
|
||||
}
|
||||
|
||||
// ByteCountSI presents a human friendly representation of a byte count. See
|
||||
// https://yourbasic.org/golang/formatting-byte-size-to-human-readable-format.
|
||||
func ByteCountSI(b uint64) string {
|
||||
const unit = 1000
|
||||
|
||||
if b < unit {
|
||||
return fmt.Sprintf("%d B", b)
|
||||
}
|
||||
|
||||
div, exp := uint64(unit), 0
|
||||
for n := b / unit; n >= unit; n /= unit {
|
||||
div *= unit
|
||||
exp++
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%.1f %cB", float64(b)/float64(div), "kMGTPE"[exp])
|
||||
}
|
||||
|
Reference in New Issue
Block a user