DEV Community

Discussion on: Use cases for persistent logs with NATS Streaming

Collapse
 
milosgajdos profile image
Milos Gajdos

Thanks for the write up. One thing I noticed in your code snippets - combination of log.Fatal and defer calls. Defer calls are never called after log.Fatal -> github.com/golang/go/issues/15402#...

Collapse
 
byronruth profile image
Byron Ruth

Good catch and thanks for letting me know! I do know this but I seem to let that bad habit creep in for examples and such. But here it is a bigger issue because properly closing connections is very important. I will update the examples shortly!

Collapse
 
byronruth profile image
Byron Ruth • Edited

I guess I didn't realize this is a bit of a pain to do. Not terrible, but easy to miss. Basically only main should call Fatal or os.Exit and no defers should be used. More generally as long as no function in the stack above this call should use a deferred function.

Edit