I'm trying to get familiar with the websocket api for Go. I found the
following code example on github which at first I thought to be a good
basic example of getting a simple websocket example up and running.
*Bad example I think*:
But then I realized something: assuming the websocket api does one
goroutine for each connection, this example is probably bad because the
author is reading/writing to a shared map. To the untrained eye, I think
it's easy for people like myself to not realize that underneath the covers
there is concurrency happening that could make this an issue. Aside from
good documentation or studying implementation details this could be a real
trap for people new to Go right?
Can anyone confirm my suspicion that the author should either lock the map
appropriately or use a channels as this following example which I think is
nicely done from the author of the Redigo library. In this example he
doesn't share anything and instead chooses to strictly communicate through
*Good example:* https://gist.github.com/garyburd/1316852
Thanks for any insight,
Still trying to wrap my head around Go as I continue with this language.
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firstname.lastname@example.org.
For more options, visit https://groups.google.com/groups/opt_out.