struct{}{}
This commit is contained in:
@@ -35,10 +35,10 @@ var (
|
||||
letterBytes = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
letterBytesNum = "0123456789"
|
||||
|
||||
flowUnitMap = map[string]string{
|
||||
"KB": "KB",
|
||||
"MB": "MB",
|
||||
"GB": "GB",
|
||||
flowUnitMap = map[string]struct{}{
|
||||
"KB": struct{}{},
|
||||
"MB": struct{}{},
|
||||
"GB": struct{}{},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -216,8 +216,8 @@ func GetNextTimeFromList(now time.Time, timeList []string) (snapshotAt time.Time
|
||||
}
|
||||
|
||||
func SplitFlowAndUnit(flowStr string) (flow float64, unit string) {
|
||||
for _, v := range flowUnitMap {
|
||||
if strings.Contains(flowStr, v) {
|
||||
for k, _ := range flowUnitMap {
|
||||
if strings.Contains(flowStr, k) {
|
||||
return utils.Str2Float64WithDefault(flowStr[:len(flowStr)-2], 0), flowStr[len(flowStr)-2:]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user