24 lines
422 B
Go
24 lines
422 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
tick := time.Tick(100 * time.Millisecond)
|
|
boom := time.After(500 * time.Millisecond)
|
|
for {
|
|
select {
|
|
case <-tick:
|
|
fmt.Println("tick.")
|
|
case <-boom:
|
|
fmt.Println("BOOM!")
|
|
return
|
|
default:
|
|
fmt.Println(" .")
|
|
time.Sleep(50 * time.Millisecond)
|
|
}
|
|
}
|
|
}
|