From fde2f767d1e97cc6b7d4d33beaa55e1b9098ec98 Mon Sep 17 00:00:00 2001 From: Mark McGranaghan Date: Sun, 14 Apr 2013 17:43:05 -0700 Subject: [PATCH] buffer channels for better gc semantics --- examples/timeouts/timeouts.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/timeouts/timeouts.go b/examples/timeouts/timeouts.go index 79d7bbf..b985eb8 100644 --- a/examples/timeouts/timeouts.go +++ b/examples/timeouts/timeouts.go @@ -13,7 +13,7 @@ func main() { // For our example, suppose we're executing an external // call that returns its result on a channel `c1` // after 2s. - c1 := make(chan string) + c1 := make(chan string, 1) go func() { time.Sleep(time.Second * 2) c1 <- "result 1" @@ -34,7 +34,7 @@ func main() { // If we allow a longer timeout of 3s, then the receive // from `c2` will succeed and we'll print the result. - c2 := make(chan string) + c2 := make(chan string, 1) go func() { time.Sleep(time.Second * 2) c2 <- "result 2"