In Concurrency Go Patterns (https://www.youtube.com/watch?v=f6kdp27TYZs) there is an example of code that looks like:
func fanIn(in1 <-chan string) <-chan string {
c:=make(chan string)
go func() {
for {
c <- <-in1
}
}()
return c
}
For me this looks very strange c <- <-in1
. What does it mean?
The c <- <-in1
stands for:
in1Val := <-in1 // read from channel in1
c <- in1Val // write the value from in1 channel to `c` channel
If you write such kind of code first time - use more this detailed code to understand what happens better.