Skip to content

[BUG] - Task not being called #266

Answered by JohnRoesler
okridgway asked this question in Q&A
Discussion options

You must be logged in to vote

Can you paste the code you're running where you're seeing that have to set it to a variable? The README is correct.

For example, this works for me:

package main

import (
	"fmt"
	"time"

	"github.com/go-co-op/gocron"
)

var task = func() {
	fmt.Println("Task is being performed.")
}

func main() {
	fmt.Println("Task is starting.")

	s := gocron.NewScheduler(time.UTC)
	s.Every(10).Do(task)

	s.StartBlocking()
}

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by JohnRoesler
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working
3 participants
Converted from issue

This discussion was converted from issue #262 on December 04, 2021 01:16.