408
//
409
//revive:disable-next-line:cognitive-complexity
410
>
func makeRange(s, field, def string, minVal, maxVal int, parseMode parseMode) ([]*schedulepb.Range, error) {
calendar.go
411
>
s = strings.TrimSpace(s)
412
>
if s == "" {
413
s = def
414
}
415
>
if s == "*" && parseMode == parseModeYear {
calendar.go
416
return nil, nil // special case for year: all is represented as empty range list
417
}
419
>
for part := range strings.SplitSeq(s, ",") {
420
>
var err error
421
>
step := 1
422
>
hasStep := false
423
>
slashes := strings.Count(part, "/")
424
>
if slashes > 1 {
425
// Inputs like "3/5/7" should yield the canonical "too many slashes" error
426
// (instead of a later strconv parse error) so tests get consistent results.
427
return nil, fmt.Errorf("%s has too many slashes", field)
428
}
430
// A single slash introduces an integer step.
431
skipParts := strings.SplitN(part, "/", 2)