go: os: os.ModeSocket is not set for domain socket files in Windows
What version of Go are you using (go version)?
$ go version go version go1.12.4 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GOARCH="amd64" GOBIN="" GOCACHE="/root/.cache/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/go" GOPROXY="" GORACE="" GOROOT="/usr/local/go" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build497560436=/tmp/go-build -gno-record-gcc-switches"
What did you do?
I created a Windows golang program to listen on a Windows domain socket. In another Windows golang program, on the file corresponding to the socket, I invoked the following code:
fi, err := os.Stat(filename)
if err != nil {
return fmt.Errorf("stat file %s failed: %v", filename, err)
}
if !fi.IsDir() {
if fi.Mode()&os.ModeSocket == 0 {
klog.V(5).Infof("Ignoring non socket file: %s", fi.Name())
return nil
}
klog.V(5).Infof("socket file found: %s", fi.Name())
return nil
}
What did you expect to see?
socket file found: filename (as in Linux)
What did you see instead?
Ignoring non socket file: filename
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 25 (17 by maintainers)
Commits related to this issue
- Fix registration socket removal on windows. Until the bug - https://github.com/golang/go/issues/33357 is fixed, os.stat wouldn't return the right mode(socket) on windows. Hence deleting the file, wit... — committed to kkmsft/node-driver-registrar by kkmsft 4 years ago
- Fix registration socket removal on windows. - Until the bug - golang/go#33357 is fixed, os.stat wouldn't return the right mode(socket) on windows. Hence deleting the file, without checking whether ... — committed to kkmsft/node-driver-registrar by kkmsft 4 years ago
- Fix registration socket removal on windows. - Until the bug - golang/go#33357 is fixed, os.stat wouldn't return the right mode(socket) on windows. Hence deleting the file, without checking whether... — committed to kkmsft/node-driver-registrar by kkmsft 4 years ago
- Fix registration socket removal on windows. - Until the bug - golang/go#33357 is fixed, os.stat wouldn't return the right mode(socket) on windows. Hence deleting the file, without checking whether ... — committed to kkmsft/node-driver-registrar by kkmsft 4 years ago
- Fix registration socket removal on windows. - Until the bug - golang/go#33357 is fixed, os.stat wouldn't return the right mode(socket) on windows. Hence deleting the file, without checking whether... — committed to kkmsft/node-driver-registrar by kkmsft 4 years ago
- Fix registration socket removal on windows. - Until the bug - golang/go#33357 is fixed, os.stat wouldn't return the right mode(socket) on windows. Hence deleting the file, without checking whether ... — committed to kkmsft/node-driver-registrar by kkmsft 4 years ago
Change https://golang.org/cl/338069 mentions this issue:
os,net: fix file mode in unix domain socket on Windows@mattn one of your related CL’s was mentioned here: https://github.com/microsoft/Windows-Containers/issues/97#issuecomment-887713195
Commenting so Github links them together.
Your patch is working for me with a socket created by
net.ListenEnvironment: Windows 11 (22000.100)