mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
fix lint and rename i with in
This commit is contained in:
parent
a83335817e
commit
0b5ce231ff
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user