summaryrefslogtreecommitdiff
path: root/watchdog.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-04-07 18:16:16 -0500
committerJeff Carr <[email protected]>2023-04-07 18:16:16 -0500
commit0a520c8ebc38640098e8d2c21711162b1697d38d (patch)
tree75ce11e40429502d36cadda6afcb11c213a7f7ba /watchdog.go
parent820067cbff754cf9a5f96c425d8f31b5949d353c (diff)
andlabs kinda works with a channel
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'watchdog.go')
-rw-r--r--watchdog.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/watchdog.go b/watchdog.go
index a9e0880..61c0247 100644
--- a/watchdog.go
+++ b/watchdog.go
@@ -27,3 +27,31 @@ func Watchdog() {
time.Sleep(watchtime * time.Second / 10)
}
}
+// https://www.reddit.com/r/golang/comments/12em87q/how_to_run_periodic_tasks/
+/*
+package main
+
+import (
+ "fmt"
+ "time"
+)
+
+func main() {
+ ticker := time.NewTicker(time.Second)
+ defer ticker.Stop()
+ done := make(chan bool)
+ go func() {
+ time.Sleep(10 * time.Second)
+ done <- true
+ }()
+ for {
+ select {
+ case <-done:
+ fmt.Println("Done!")
+ return
+ case t := <-ticker.C:
+ fmt.Println("Current time: ", t)
+ }
+ }
+}
+*/