Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Be careful with locks in the form "x.Lock(); x.DoSomething(); x.Unlock()". If DoSomething panics, you will still be holding the lock, and that's pretty much the end of your program.

Interesting, thanks. But isn't panicking the end of your program anyway? Could you provide another example where no using defer causes problems?



Not necessarily. Panics can be recovered and the stdlib http server recovers panics from handlers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: