fix(util): fix the bug of ParseSizeToBit

This commit is contained in:
HuangJiaLuo 2021-10-04 16:21:48 +08:00
parent 29c5aca40d
commit dbc0467de4
1 changed files with 3 additions and 2 deletions

View File

@ -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")
}