refactor: use WaitGroup.Go to simplify code (#5162)

Signed-off-by: asttool <asttool@outlook.com>
This commit is contained in:
asttool 2025-10-10 22:28:35 +08:00 committed by GitHub
parent d7e751997d
commit 54e3c13435
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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