1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-26 13:48:49 +08:00
hybridgroup.gobot/examples/every_done.go
deadprogram 491b8aa35a [core] Return when Every is sent done on its channel
Signed-off-by: deadprogram <ron@hybridgroup.com>
2016-07-03 10:52:11 +02:00

31 lines
404 B
Go

package main
import (
"fmt"
"time"
"github.com/hybridgroup/gobot"
)
func main() {
gbot := gobot.NewGobot()
robot := gobot.NewRobot(
"hello",
func() {
done := gobot.Every(500*time.Millisecond, func() {
fmt.Println("Greetings human")
})
gobot.After(5*time.Second, func() {
done <- true
fmt.Println("We're done here")
})
},
)
gbot.AddRobot(robot)
gbot.Start()
}