For 3 different and distinct "c"
for _, c := range u.components { // u.components has 3 members
fmt.Printf("%v %v", c.name, c.channel) // prints 3 distinct name/channel pairs
go c.Listen(); // a method of c that listens on channel c.channel
}
...launches 3 identical goroutines in which c.name and c.channel are identical.
The long version (commented, short code): https://play.golang.org/p/mMQb_5jLjm
This is my first Go program, I'm sure I'm missing something obvious. Any ideas?
Thank you.