A cron expression is five fields separated by whitespace - minute, hour, day-of-month, month, day-of-week. Before parsing anything you have to split the line into exactly those five parts, and reject a line that has the wrong number.
Split an expression on whitespace into five fields, or return an error if there are not exactly five.
A standard cron expression is a single line of five fields separated by spaces or tabs: minute, hour, day-of-month, month, and day-of-week, always in that order. Everything else in this project is about interpreting one field at a time, so the very first job is to chop the line into exactly five pieces. Splitting on any run of whitespace (not a single space) means extra spacing between fields does not matter, which is how real crontabs are written.
The one rule to enforce today is the count: a line with four or six fields is not a valid five-field cron expression, so reject it with a clear error rather than guessing what the writer meant. Pin both the good split and the wrong-count failure now - every later lesson receives exactly five field strings and never has to worry about the shape of the line again.
func SplitFields(expr string) ([]string, error) {f := strings.Fields(expr) // splits on any run of whitespaceif len(f) != 5 {return nil, fmt.Errorf("expected 5 fields, got %d", len(f))}return f, nil}