From 42355b17eeba04218a2764c82fccdda8efa6d11a Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Thu, 28 Apr 2022 09:56:26 +0700 Subject: [PATCH] shorter common.ByteCount for shorter logs #433 --- common/bytes.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/bytes.go b/common/bytes.go index 8659a6113..6af893ac5 100644 --- a/common/bytes.go +++ b/common/bytes.go @@ -21,14 +21,14 @@ import "fmt" func ByteCount(b uint64) string { const unit = 1024 if b < unit { - return fmt.Sprintf("%d B", b) + return fmt.Sprintf("%db", b) } div, exp := uint64(unit), 0 for n := b / unit; n >= unit; n /= unit { div *= unit exp++ } - return fmt.Sprintf("%.1f %ciB", + return fmt.Sprintf("%.1f%cb", float64(b)/float64(div), "KMGTPE"[exp]) }