4 ms·
I've never encountered a situation in Go where I'm passing file handles around like this. In practice you'd probably have one goroutine manage the resource and
by wybiral 9y ago
I've never encountered a situation in Go where I'm passing file handles around like this.
In practice you'd probably have one goroutine manage the resource and its lifespan then other code would communicate with that goroutine using channels.
- arghwhat 9y agoYou might pass an os.File or a network connection as an io.Reader or io.Writer to something that might keep it. The GC actually has an extension to sorta have destructors to help with leaking fd's from forgotten os.File's (runtime.SetFinalizer). However, having coded Go for quite a few years by now, I haven't found it to be an issue at all.