fix(util): fix the bug of ParseSizeToBit
This commit is contained in:
parent
29c5aca40d
commit
dbc0467de4
|
@ -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")
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue