refactor: use WaitGroup.Go to simplify code

Signed-off-by: asttool <asttool@outlook.com>
This commit is contained in:
asttool 2025-10-10 15:15:56 +08:00
parent d7e751997d
commit cf8f6de28a
1 changed files with 2 additions and 4 deletions

View File

@ -306,11 +306,9 @@ func (c *Cron) runScheduler() {
// startJob runs the given job in a new goroutine.
func (c *Cron) startJob(j Job) {
c.jobWaiter.Add(1)
go func() {
defer c.jobWaiter.Done()
c.jobWaiter.Go(func() {
j.Run()
}()
})
}
// now returns current time in c location.