Some thoughts to direct your initial planning --
-
structs are a great way to keep things together. If you're gonna have a loop that writes to a websocket and you need to manage a lock for that websocket, it might be a good idea to keep a websocket and a lock for it in a struct
-
this pattern is great for handling messages from multiple channels
for { select { case data, ok := <-c: // c and d are channels
case data, ok := <-c: // c and d are# do something case data, ok := <-d: # do something } } -
Make sure you lock before writing to a websocket so that you don't get a concurrent write error
-
If your server quits too early it might be because of waitgroups -- Make sure you actually wait for waitgroups and add goroutines you want to wait for to them.
-
Ask any questions you need to, my slack pm is always open and I'll try to help you out as soon as I can.