News for hackers. Stuff that matters.
Re:Go Concurrency by brunoqc on Thursday March 28, 2013 @11:03AM (#5455191)
Anyone has any idea why the code from slide 5 doesn't print anything? http://play.golang.org/p/NtjHL3F1LC
Re:Go Concurrency by jgrahamc on Thursday March 28, 2013 @11:04AM (#5455198)
Because I shortened it for the slide. Add something at the end of main() that waits a bit (say time.Sleep(time.Minute)). What's happening is main() terminates before those goroutines get to run.

http://play.golang.org/p/rJ9eE7p7gz

Re:Go Concurrency by brunoqc on Thursday March 28, 2013 @11:09AM (#5455230)
Oh thanks! Sorry for the noise.
Re:Go Concurrency by Evbn on Thursday March 28, 2013 @11:24AM (#5455347)
You should open a channel, pass it to the go routine, and send a completion message from the goroutine, and then read from it before the end of main.

3 lines of code to show a cool festure and avoid an embarassing bug.