Created
April 14, 2021 13:21
-
-
Save tranphuquy19/67e8e0ecc2931bdd9e00a100429b0e50 to your computer and use it in GitHub Desktop.
GoLang-Run-Forever
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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