From cfce92a19aecf947edd896d1a567f04658fcfc9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= <2000michal@wp.pl> Date: Wed, 30 Oct 2024 09:26:08 +0100 Subject: [PATCH] feat(managerclient): include B or iB in SizeSuffix display It is nicer to see: "Size: 10B" instead of "Size: 10" or "Size: 20KiB" instead of "Size: 20k". --- v3/pkg/managerclient/sizesuffix.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/v3/pkg/managerclient/sizesuffix.go b/v3/pkg/managerclient/sizesuffix.go index 173e2b6513..49ada81e4a 100644 --- a/v3/pkg/managerclient/sizesuffix.go +++ b/v3/pkg/managerclient/sizesuffix.go @@ -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