On Wednesday, August 24, 2016 at 9:44:04 PM UTC+8, Chintan Sheth wrote:
>
> I am using select statement to dispatch work coming from multiple 
> goroutines, the variables used to consume the channel are allocated 
> manually as I am recycling those
>
>
> for {
>  a := getA()
>  b := getB()
>  select {
>  case a = <-chan1:
>   go doSomething(&a)
>  case b = <-chan2:
>   go doSomething2(&b)
>  }
> }
>
>
> This obviously does not work while listening on more than one channel, as 
> I wasting a get() call for the other type, is there any way to do some 
> "prework" before consuming the channel
>


 for {
 select {
 case a := <-chan1:
  go doSomething(&a)
 case b := <-chan2:
  go doSomething2(&b)
 }
}

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to