Source file tour/concurrency/default-selection.go
1 //go:build OMIT 2 3 package main 4 5 import ( 6 "fmt" 7 "time" 8 ) 9 10 func main() { 11 tick := time.Tick(100 * time.Millisecond) 12 boom := time.After(500 * time.Millisecond) 13 for { 14 select { 15 case <-tick: 16 fmt.Println("tick.") 17 case <-boom: 18 fmt.Println("BOOM!") 19 return 20 default: 21 fmt.Println(" .") 22 time.Sleep(50 * time.Millisecond) 23 } 24 } 25 } 26