4 ms·
Doing defer in a loop is usually a bug in your Go code. Sure there are legit use cases of it, but in ~90% of the time what you really want to do is (in Go, I ha
by fishywang 6y ago
Doing defer in a loop is usually a bug in your Go code. Sure there are legit use cases of it, but in ~90% of the time what you really want to do is (in Go, I haven't used C recently so not sure how to do lambdas correctly):
for i := 0; i < 10; i++ {
func(i int) {
defer foo(i)
// other code
}(i)
}