Make sure the library compiles for windows

systemd sockets are not applicable for windows. However compilation
should not fail on windows
This commit is contained in:
2025-07-17 20:34:55 -04:00
parent 97b73fb442
commit 80808310ce
3 changed files with 29 additions and 11 deletions

19
fd_unix.go Normal file
View File

@@ -0,0 +1,19 @@
//go:build unix
package anyhttp
import (
"net"
"os"
"syscall"
)
func makeFdListener(fd int, name string) (net.Listener, error) {
fdFile := os.NewFile(uintptr(fd), name)
l, err := net.FileListener(fdFile)
if err != nil {
return nil, err
}
syscall.CloseOnExec(fd)
return l, nil
}