Channels in web application

Hi,

In our web application, we have used channels to perform some parallel operation.
case 1: When I use the channel in global scope , during the second request it hungs up at the place before writing the channel 1.
case 2: when I use inside the method and pass the channels to the go routine, it works properly.

https://play.golang.org/p/3nNl9RK0Tbk (case 2 code)

My question is that if it thinks during the second request channels are closed in case 1 , it should throw panic saying channels are closed and cannot write to closed channels. But it is not throwing panic and just hung there. Kindly let me know if you need any details.

How does the code for case 1 differ from the one in the Playground?

case 1 code : https://play.golang.org/p/YwLinT_e--r
All channels are initialised at global scope and not inside method

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.