The gocron package provides primitives to parse a Cron expression and iterate over the activation times.
go get github.com/Gilthoniel/gocronThis package implements the specification found in Wikipedia and includes some advanced usages from the Quartz scheduler.
| Field name | Allowed values | Allowed special characters |
|---|---|---|
| Seconds | 0-59 | , - * / |
| Minutes | 0-59 | , - * / |
| Hours | 0-59 | , - * / |
| Day of month | 1-31 | , - * ? / L |
| Month | 1-12 | , - * / |
| Day of week | 0-6 or SUN-SAT | , - * ? / L # |
| Years | 1-9999 | , - * / |
*can be used to select all values within a field (e.g. every second, every minute, ...)?can be used for no specific value in the day field or the week day field.-can be used to specify an inclusive range (e.g.1-3means values 1, 2, and 3).,can be used to list values (e.g.1,2,3means values 1, 2 and 3)./can be used to specify an interval (e.g.1/5means values 1, 6, 11, 16, etc...).Lwhen used in the month field specifies the last day of the month and Saturday when used in the week day field. Using a digit before the character in the week day field specifies the nth last week day of the month (e.g.1Lfor the last Monday of the month). An offset can also be used for the month field (e.g.L-2for the second last day of the month).#can be used to specify the nth week day of the month (e.g.6#3for the third (3) Saturday (6) of the month).