On Mon, 3 Sep 2018 06:22:27 +0000
Anik Hasibul <anik3...@gmail.com> wrote:

> Can you please provide an example? I am new to golang.
> ________________________________

Create N client receivers with channel and save the list of client
channel as list,

for x := 0; x < 5; x++ {
  cl := make(chan int, 1)
  chanClients = append(chanClients, cl)
  go clientReceiver(cl)
}

Then pass the main notification channel and list of client channels to
master, and propagate notification to all client channels when data
arrived,

func masterReceiver(notif chan int, chanClients []chan int) {
  for n := range notif {
    for _, ch := range chanClients {
      ch <- n
    }
  }
}

-- 
{ "github":"github.com/shuLhan", "site":"kilabit.info" }

-- 
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