go-chat
go-chat copied to clipboard
Access to the clients map is not concurrency-safe
A friend of mine is trying to learn Go and took this as an example. Unfortunately, it is a great example of a program that fails to be concurrency-safe.
The access to the clients map can be modified by any new connection in the goroutine spawned by http.Serve while being concurrently read-accessed in the handleMessages goroutine whenever an already established websocket writes data to the server.