[BUG] Fix Data race when using RunByTag by seunghyupoh3517 · Pull Request #356 · go-co-op/gocron (original) (raw)

What does this do?

Resolves #350 Job lastRun was causing the data race when RunByTag. Wraps the job.copy in Scheduler.run() into separate method, addJobDetails and added locks on job.runCount, job.lastRun.

Which issue(s) does this PR fix/relate to?

Resolves #350

List any changes that modify/break current functionality

Have you included tests for your changes?

Updated TestScheduler_RunByTag in shceduler_test.go to simulate multiple tasks being run by tag.

Did you document any new/modified functionality?

Notes

Added ErrInvalidFunctionParameters = errors.New("length of function parameters must match job function parameters") But if this case will never be happening, update the job.error. Otherwise, it would be better to return the error.