3 ms·
Defer only defers to the end of the scope so, "no" if the handle is one that needs to survive the function it was opened in.
by spooneybarger 2y ago
Defer only defers to the end of the scope so, "no" if the handle is one that needs to survive the function it was opened in.
- Kon-Peki 2y agoYou can do this in many ways, but you can also do it like this: Start a goroutine and use channels to communicate and coordinate reading/writing. Use defer in the goroutine.