Hacker News new | past | comments | ask | show | jobs | submit login

Also read the official blog post on defer: https://blog.golang.org/defer-panic-and-recover

It covers about half of these gotchas by laying out how the defer statement works in plain English. The other half (like how closures work inside loops in Go) are covered elsewhere in the language tour.

I do really like the visualizations! Makes it very clear how these mechanics work.




The content is good, and it is accurate, but even though defer can be a bit tricky this blog post series seems to literally be describing the entire semantics of "defer" as "gotchas". It's not that tricky!


Well, it depends. Upgoing posts will go deeper on defer.


Thanks! That post definitely a must read.

Btw, the first part was more advanced (but again for beginners and intermediate gophers) -> https://blog.learngoprogramming.com/gotchas-of-defer-in-go-1...




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: