The operating system doesn't clean up the file that announcing created, so we have to clean it up ourselves. There's a race here--we can't know for sure whether someone else has come along and replaced our socket name already-- but this sequence (remove then close) is at least compatible with the auto-remove sequence in ListenUnix. It's only non-Go programs that can mess us up. Even if there are racy calls to Close, we want to unlink only for the first one.
SetUnlinkOnClose sets whether the underlying socket file should be removed from the file system when the listener is closed. The default behavior is to unlink the socket file only when package net created it. That is, when the listener and the underlying socket file were created by a call to Listen or ListenUnix, then by default closing the listener will remove the socket file. but if the listener was created by a call to FileListener to use an already existing socket file, then by default closing the listener will not remove the socket file.
The pages are generated with Goldsv0.3.2-preview. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.