A
A
alst1612016-11-20 23:07:53
go
alst161, 2016-11-20 23:07:53

Is it possible to send different channels to a function?

The essence is as follows: there is a function, a goroutine (f2) that takes two channels, performs some actions and writes the results to these channels. There is a function, a goroutine (f1) to which data is transferred and it must create different channels and transfer them to f2, then it waits for responses from these channels, receives and processes them further. So if I just create a channel in f2 and these goroutines will be several, then different ones will take different channels? How can I make sure everyone listens to their own channel?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
bnytiki, 2016-11-20
@bnytiki

Well, for example, like this:

func runGoRoutine1(input chan bool) {

   go func() {

                  data:= <-input
                  ...

   }

}

A
Andrey Vorobyov, 2016-11-27
@Santacruz

chan chan workType - this is also possible

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question