1
0
gotour-notes/concurrency/default-select/go.go

24 lines
313 B
Go

package main
import (
"fmt"
"time"
)
func main() {
tick := time.Tick(time.Second)
boom := time.After(time.Second * 10)
for {
select {
case <-tick:
fmt.Println("tick.")
case <-boom:
fmt.Println("BOOM!")
return
default:
fmt.Println(" .")
time.Sleep(time.Millisecond * 100)
}
}
}