Added ability to run & schedule tasks on a period

This commit is contained in:
🐙PiperYxzzy
2022-05-04 20:49:23 +02:00
parent 65c9309f43
commit d2dcd8c94b
2 changed files with 29 additions and 0 deletions

18
scheduled/scheduled.go Normal file
View File

@@ -0,0 +1,18 @@
package scheduled
import (
"fmt"
"time"
)
type Scheduled func() (string, time.Duration)
func Schedule(f Scheduled) {
print, wait := f()
fmt.Println(print)
go func(w time.Duration) {
time.Sleep(w)
Schedule(f)
}(wait)
}