Skip to content

Commit

Permalink
feat(managerclient): include B or iB in SizeSuffix display
Browse files Browse the repository at this point in the history
It is nicer to see:
"Size: 10B" instead of "Size: 10" or
"Size: 20KiB" instead of "Size: 20k".
  • Loading branch information
Michal-Leszczynski committed Nov 4, 2024
1 parent 4f72868 commit cfce92a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions v3/pkg/managerclient/sizesuffix.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,25 @@ func (x SizeSuffix) string() (string, string) {
case x < 0:
return "off", ""
case x == 0:
return "0", ""
return "0", "B"
case x < 1<<10:
scaled = float64(x)
suffix = ""
suffix = "B"
case x < 1<<20:
scaled = float64(x) / (1 << 10)
suffix = "k"
suffix = "KiB"
case x < 1<<30:
scaled = float64(x) / (1 << 20)
suffix = "M"
suffix = "MiB"
case x < 1<<40:
scaled = float64(x) / (1 << 30)
suffix = "G"
suffix = "GiB"
case x < 1<<50:
scaled = float64(x) / (1 << 40)
suffix = "T"
suffix = "TiB"
default:
scaled = float64(x) / (1 << 50)
suffix = "P"
suffix = "PiB"
}
if math.Floor(scaled) == scaled {
return fmt.Sprintf("%.0f", scaled), suffix
Expand Down

0 comments on commit cfce92a

Please sign in to comment.