4 ms·
A Go Gotcha: When Closures and Goroutines Collide
- programd 12y agoNever use closures. If it's worth writing a function at all, it's worth naming it and putting it outside of the current function. It is code you can't reuse without copy/paste since it's just embedded in another function like that. There's also a cognitive load in switching from reading the flow of the enclosing function into some other anonymous function. Cognitive load leads to errors - viz the submission. IMHO closures are a toxic infection. I blame Javascript.