fix lint and rename i with in

This commit is contained in:
Alan.sung 2023-10-04 12:36:17 +08:00
parent a83335817e
commit 0b5ce231ff

View File

@ -211,26 +211,26 @@ func toLocalInterval(interval types.Interval) (string, error) {
return "", fmt.Errorf("interval %s is not supported", interval)
}
switch i := interval.String(); {
case strings.HasSuffix(i, "m"):
return i, nil
case strings.HasSuffix(i, "mo"):
switch in := interval.String(); {
case strings.HasSuffix(in, "m"):
return in, nil
case strings.HasSuffix(in, "mo"):
return "1Mutc", nil
default:
hdwRegex := regexp.MustCompile("\\d+[dw]$")
if hdwRegex.Match([]byte(i)) {
return strings.ToUpper(i) + "utc", nil
hdwRegex := regexp.MustCompile(`\d+[dw]$`)
if hdwRegex.Match([]byte(in)) {
return strings.ToUpper(in) + "utc", nil
}
hdwRegex = regexp.MustCompile("(\\d+)[h]$")
if fs := hdwRegex.FindStringSubmatch(i); len(fs) > 0 {
hdwRegex = regexp.MustCompile(`(\d+)[h]$`)
if fs := hdwRegex.FindStringSubmatch(in); len(fs) > 0 {
digits, err := strconv.ParseInt(string(fs[1]), 10, 64)
if err != nil {
return "", fmt.Errorf("interval %s is not supported", interval)
}
if digits >= 6 {
return strings.ToUpper(i) + "utc", nil
return strings.ToUpper(in) + "utc", nil
} else {
return strings.ToUpper(i), nil
return strings.ToUpper(in), nil
}
}