Scheduler.New
Overview
New creates a scheduler and starts its internal runner.
Part of the cron package — Node.js analog: node-cron.
Method on Scheduler — call it on a value of that type after constructing or receiving one from a constructor.
Signature
go
func New() *SchedulerCompare: Node.js · Standard Go · gox
js
const job = cron.schedule('* * * * *', fn);go
c := cron.New()
c.AddFunc(spec, fn)
c.Start()go
import "github.com/sahilkhaire/gox/cron"
sched := cron.New()
sched.Schedule("* * * * *", fn)Example
go
import "github.com/sahilkhaire/gox/cron"
sched := cron.New()
sched.Schedule("* * * * *", fn)Tips
Obtain a Scheduler value first (see constructors on the package overview), then call New.
Standard library alternative
Use the standard library directly:
go
c := cron.New()
c.AddFunc(spec, fn)
c.Start()