Go Cheatsheet - Select with Timer & Ticker
Select
Select channels with timeout
Use time.After
select {
case res := <-ch:
fmt.Println(res)
case <-time.After(1 * time.Second):
fmt.Println("timeout 1")
}
Or use time.NewTimer
timer1 := time.NewTimer(2 * time.Second)
select {
case <-quit:...
hn.0xbf.me1 min read