Broadcast messages to multiple WebSocket clients by maintaining a map of connections and iterating through it to write data to each client.
var clients = make(map[*websocket.Conn]bool)
func broadcast(message []byte) {
for client := range clients {
err := client.WriteMessage(websocket.TextMessage, message)
if err != nil {
client.Close()
delete(clients, client)
}
}
}