The doc comment for win32File indicates the file will be closed when the Go object is garbage collected.
// win32File implements Reader, Writer, and Closer on a Win32 handle without blocking in a syscall.
// It takes ownership of this handle and will close it if it is garbage collected.
type win32File struct {
handle windows.Handle
wg sync.WaitGroup
wgLock sync.RWMutex
closing atomicBool
socket bool
readDeadline deadlineHandler
writeDeadline deadlineHandler
}
However, grepping through the codebase I cannot find a single call to runtime.SetFinalizer. I'm curious: if this doc comment is true, how is the file being closed on garbage collection without any such calls to runtime.SetFinalizer?
I'm writing some logic that serves net.Conn (provided by this package), and I want to know if I need to take care of setting a finalizer myself or not.
The doc comment for
win32File
indicates the file will be closed when the Go object is garbage collected.However, grepping through the codebase I cannot find a single call to
runtime.SetFinalizer
. I'm curious: if this doc comment is true, how is the file being closed on garbage collection without any such calls toruntime.SetFinalizer
?I'm writing some logic that serves
net.Conn
(provided by this package), and I want to know if I need to take care of setting a finalizer myself or not.Thanks!