From 6e05ffaf0a04467b304046ebf7acd71e9362e3bc Mon Sep 17 00:00:00 2001 From: Sandy Xu Date: Fri, 31 May 2024 17:24:47 +0800 Subject: [PATCH] utils: support unit 'B' when parsing bytes --- pkg/utils/humanize.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/utils/humanize.go b/pkg/utils/humanize.go index 3d0b92218c1d..22cce0674440 100644 --- a/pkg/utils/humanize.go +++ b/pkg/utils/humanize.go @@ -41,6 +41,7 @@ func ParseBytesStr(key, str string, unit byte) uint64 { if err == nil { var shift int switch unit { + case 'B': case 'k', 'K': shift = 10 case 'm', 'M': @@ -59,7 +60,7 @@ func ParseBytesStr(key, str string, unit byte) uint64 { val *= float64(uint64(1) << shift) } if err != nil { - logger.Fatalf("Invalid value \"%s\" for \"%s\"", str, key) + logger.Fatalf("Invalid value \"%s\" for \"%s\": %s", str, key, err) } return uint64(val) }