diff --git a/example56-context-timeout/main.go b/example56-context-timeout/main.go index 210e2c0..f5601e0 100644 --- a/example56-context-timeout/main.go +++ b/example56-context-timeout/main.go @@ -5,7 +5,7 @@ import ( ) func main() { - output := make(chan int, 1) + output := make(chan int, 10) go func() { for i := 0; i < 30; i++ { @@ -18,6 +18,8 @@ func main() { for { select { case val := <-output: + // simulate slow consumer + time.Sleep(500 * time.Millisecond) println("output:", val) // how to fix the timeout issue? case <-time.After(1 * time.Second):