More Gotchas of Defer in Go, Part II
blog.learngoprogramming.com
More Gotchas of Defer in Go, Part II
1–10 of 55 posts
Re: More Gotchas of Defer in Go, Part II
#2Re: More Gotchas of Defer in Go, Part II
#3It 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.
Re: More Gotchas of Defer in Go, Part II
#4Re: More Gotchas of Defer in Go, Part II
#5 for i := 0; i Re: More Gotchas of Defer in Go, Part II
#6I think most of the people who understand the basic principles of how computers (and many languages) work wouldn’t be surprised by any of the „gotcha” described in this article. It seems to be written for people who just started working with golang without any or little knowledge about information technology.
Re: More Gotchas of Defer in Go, Part II
#7I think most of the people who understand the basic principles of how computers (and many languages) work wouldn’t be surprised by any of the „gotcha” described in this article. It seems to be written for people who just started working with golang without any or little knowledge about information technology.
Re: More Gotchas of Defer in Go, Part II
#8Re: More Gotchas of Defer in Go, Part II
#9Also 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.
Re: More Gotchas of Defer in Go, Part II
#10#4 can also be fixed with: for i := 0; i
I'm curious what good use-case there is for this, that the language bothered to support and allow this to even compile.
Duplicate variable name declaration + referencing in the same scope is unintuitive at best, and just seems wrong.