News for hackers. Stuff that matters.
Re:Go Bloviations by Jabbles on Tuesday September 25, 2012 @05:37AM (#4569456)
Go doesn't have non-blocking receives anymore.

  value, ok := <- ch
will block, always. Iff the channel is closed, ok will be false, allowing you to distinguish between a zero value sent on the channel, and the zero value you get back if you try to receive on a closed channel. Receiving from a nil channel always blocks.

Select statements allow you to check if a channel has had a value sent on it.

http://golang.org/ref/spec#Receive_operator

https://groups.google.com/d/msg/golang-nuts/Z63l4LDOlsI/54uT...

http://golang.org/ref/spec#Select_statements

Re:Go Bloviations by crawshaw on Tuesday September 25, 2012 @09:19AM (#4570142)
For those who didn't dive into the spec, the non-blocking recieve syntax has changed to use the select statement:

  func f(ch chan int) {
  	select {
  	case v := <-ch:
  		fmt.Println("got", v)
  	default:
  		fmt.Println("did not block")
  	}
  }
http://play.golang.org/p/ql0qSUVXeX