Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to avoid panics in the code #13

Open
Gerifield opened this issue Jan 9, 2021 · 1 comment
Open

Try to avoid panics in the code #13

Gerifield opened this issue Jan 9, 2021 · 1 comment

Comments

@Gerifield
Copy link

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.)

@VikingPingvin
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants