gobot.io/x/gobot/v2@v2.1.0/examples/every_done.go (about) 1 //go:build example 2 // +build example 3 4 // 5 // Do not build by default. 6 7 package main 8 9 import ( 10 "fmt" 11 "time" 12 13 "gobot.io/x/gobot/v2" 14 ) 15 16 func main() { 17 robot := gobot.NewRobot( 18 "hello", 19 func() { 20 done := gobot.Every(750*time.Millisecond, func() { 21 fmt.Println("Greetings human") 22 }) 23 24 gobot.After(5*time.Second, func() { 25 done.Stop() 26 fmt.Println("We're done here") 27 }) 28 }, 29 ) 30 31 robot.Start() 32 }