From 9f04e5a8eaf24b0391766fc4904f7f1f08d2d1e8 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Tue, 14 Nov 2023 16:33:09 -0800 Subject: [PATCH] format bytes --- format/bytes.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/format/bytes.go b/format/bytes.go index 1cf5a762..471bdf49 100644 --- a/format/bytes.go +++ b/format/bytes.go @@ -7,10 +7,13 @@ const ( KiloByte = Byte * 1000 MegaByte = KiloByte * 1000 GigaByte = MegaByte * 1000 + TeraByte = GigaByte * 1000 ) func HumanBytes(b int64) string { switch { + case b > TeraByte: + return fmt.Sprintf("%.1f TB", float64(b)/TeraByte) case b > GigaByte: return fmt.Sprintf("%.1f GB", float64(b)/GigaByte) case b > MegaByte: