VikingPingvin/go-locker

Try to avoid panics in the code

Opened this issue · 1 comments

log.Panic().Err(err).Msg("Can't establish connection to the server!!!")

Here using a defer wg.Done() could simplify your code, but as your comment suggests you can't do that because of the panic.

Panicking is okay-is in the main, but you should definitely avoid it anywhere else.
There are different ways to return errors from even a goroutin, I'd suggest you to experiment with channels maybe or you could simply return an error value with a param too. (Pointers could be useful.)

I definately need to think about how I approach breaking errors, as in a constant running Server app, self-healing is pretty much a must.

Many of my function completely disregard error returns, even if they DO return an error, it's simply not checked.
It's something I have to come back at some point to resolve.