How to broadcast message using channel
问题 I am new to go and I am trying to create a simple chat server where clients can broadcast messages to all connected clients. In my server, I have a goroutine (infinite for loop) that accepts connection and all the connections are received by a channel. go func() { for { conn, _ := listener.Accept() ch <- conn } }() Then, I start a handler (goroutine) for every connected client. Inside the handler, I try to broadcast to all connections by iterating through the channel. for c := range ch { conn