struct{}{}

This commit is contained in:
suyl
2021-07-22 17:07:26 +08:00
parent a6cdea6610
commit 08cdbe84cf
3 changed files with 9 additions and 8 deletions

View File

@@ -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:]
}
}