4 ms·
Yes, it is odd to pass the address of a local variable from the enclosing scope like this to a go routine.
by thwarted 6y ago
Yes, it is odd to pass the address of a local variable from the enclosing scope like this to a go routine.
- masklinn 6y agoWell that's true in the sense that usually you'd just close over it, which is the classic broken case of closing over a mutable binding: https://play.golang.org/p/40FRmvhifBl https://play.golang.org/p/40FRmvhifBl I assume GGP's contrived example is to show the underlying mechanics of the issue.