From dbc0467de4132b17c45b94b75fde7ccc4b6327f3 Mon Sep 17 00:00:00 2001 From: HuangJiaLuo <1820799930@qq.com> Date: Mon, 4 Oct 2021 16:21:48 +0800 Subject: [PATCH] fix(util): fix the bug of ParseSizeToBit --- pkg/util/memory.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/util/memory.go b/pkg/util/memory.go index c4c32aa..6b7f64d 100644 --- a/pkg/util/memory.go +++ b/pkg/util/memory.go @@ -1,6 +1,7 @@ package util import ( + "gitee.com/timedb/wheatCache/pkg/errorx" "regexp" "strconv" "strings" @@ -8,7 +9,7 @@ import ( // ParseSizeToBit // 支持MB, GB, KB, 格式 "5KB" 或者 "5kb"等等 -func ParseSizeToBit(size string) int64 { +func ParseSizeToBit(size string) interface{} { sizes := regexp.MustCompile("^\\d+") sizeRes := sizes.FindAllString(size, 1) @@ -23,7 +24,7 @@ func ParseSizeToBit(size string) int64 { } else if strings.ToUpper(unit[1]) == "GB"{ return Res * 1024 *1024 * 1024 * 8 } - return -1 + return errorx.New("your size is wrong") }