79155890

Date: 2024-11-04 14:52:12
Score: 0.5
Natty:
Report link

There are some schedulers that exist to avoid this problem and also make it more robust if the program stops for a longer time period.

https://github.com/reugn/go-quartz is one of them and allows you to trigger tasks with different scheduling methods (CRON, durations, ...). Quartz can persist its triggers to a db so that even if your program stops for a long time when it resumes it will still retrieve its schedule.

You also have https://github.com/go-co-op/gocron which is well known in the go community.

I recommend using a clear and established library but you could also look at their implementation and create your own solution if you prefer.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Félix