Skip to content

Instantly share code, notes, and snippets.

@tranphuquy19
Created April 14, 2021 13:21
Show Gist options
  • Save tranphuquy19/67e8e0ecc2931bdd9e00a100429b0e50 to your computer and use it in GitHub Desktop.
Save tranphuquy19/67e8e0ecc2931bdd9e00a100429b0e50 to your computer and use it in GitHub Desktop.
GoLang-Run-Forever
package main
import (
"fmt"
"time"
"github.com/go-co-op/gocron"
)
var task = func() {
fmt.Println(time.Now().Clock())
}
var task2 = func() {
fmt.Println(123)
}
func main() {
s := gocron.NewScheduler(time.UTC)
s.Every(5).Seconds().Do(task)
s.Every(10).Seconds().Do(task2)
s.StartAsync()
for {
select {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment