gobot.io/x/gobot@v1.16.0/examples/every_done.go (about)

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