--- /dev/null
+// Copyright 2025 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package net
+
+func supportsUnixSocket() bool {
+ return false
+}
import (
"internal/testenv"
"os"
- "os/exec"
"runtime"
- "strconv"
"strings"
"testing"
)
-var unixEnabledOnAIX bool
-
-func init() {
- if runtime.GOOS == "aix" {
- // Unix network isn't properly working on AIX 7.2 with
- // Technical Level < 2.
- // The information is retrieved only once in this init()
- // instead of everytime testableNetwork is called.
- out, _ := exec.Command("oslevel", "-s").Output()
- if len(out) >= len("7200-XX-ZZ-YYMM") { // AIX 7.2, Tech Level XX, Service Pack ZZ, date YYMM
- aixVer := string(out[:4])
- tl, _ := strconv.Atoi(string(out[5:7]))
- unixEnabledOnAIX = aixVer > "7200" || (aixVer == "7200" && tl >= 2)
- }
- }
-}
-
// testableNetwork reports whether network is testable on the current
// platform configuration.
func testableNetwork(network string) bool {
return false
}
}
- case "unix", "unixgram":
+ case "unixgram":
switch runtime.GOOS {
- case "android", "ios", "plan9", "windows":
+ case "windows":
return false
- case "aix":
- return unixEnabledOnAIX
+ default:
+ return supportsUnixSocket()
}
+ case "unix":
+ return supportsUnixSocket()
case "unixpacket":
switch runtime.GOOS {
case "aix", "android", "darwin", "ios", "plan9", "windows":
--- /dev/null
+// Copyright 2025 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build unix || js || wasip1
+
+package net
+
+import (
+ "os/exec"
+ "runtime"
+ "strconv"
+)
+
+var unixEnabledOnAIX bool
+
+func init() {
+ if runtime.GOOS == "aix" {
+ // Unix network isn't properly working on AIX 7.2 with
+ // Technical Level < 2.
+ // The information is retrieved only once in this init()
+ // instead of everytime testableNetwork is called.
+ out, _ := exec.Command("oslevel", "-s").Output()
+ if len(out) >= len("7200-XX-ZZ-YYMM") { // AIX 7.2, Tech Level XX, Service Pack ZZ, date YYMM
+ aixVer := string(out[:4])
+ tl, _ := strconv.Atoi(string(out[5:7]))
+ unixEnabledOnAIX = aixVer > "7200" || (aixVer == "7200" && tl >= 2)
+ }
+ }
+}
+
+func supportsUnixSocket() bool {
+ switch runtime.GOOS {
+ case "android", "ios":
+ return false
+ case "aix":
+ return unixEnabledOnAIX
+ }
+ return true
+}
--- /dev/null
+// Copyright 2025 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package net
+
+import "internal/syscall/windows"
+
+func supportsUnixSocket() bool {
+ return windows.SupportUnixSocket()
+}
switch network {
case "tcp", "udp", "ip":
return errors.New("ambiguous network: " + network)
+ case "unix", "unixpacket", "unixgram":
+ fn = func(s uintptr) {
+ const SO_ERROR = 0x1007
+ _, operr = syscall.GetsockoptInt(syscall.Handle(s), syscall.SOL_SOCKET, SO_ERROR)
+ }
default:
switch network[len(network)-1] {
case '4':
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build !plan9 && !windows
+//go:build !plan9
package net
}
switch runtime.GOOS {
- case "android", "linux":
+ case "android", "linux", "windows":
if laddr == "" {
laddr = "@" // autobind feature
}
// FileListener should not.
t.Run("FileListener", func(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("skipping: FileListener not implemented on windows")
+ }
l := listen(t)
f, _ := l.File()
l1, _ := FileListener(f)
})
t.Run("FileListener/SetUnlinkOnClose(true)", func(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("skipping: FileListener not implemented on windows")
+ }
l := listen(t)
f, _ := l.File()
l1, _ := FileListener(f)
})
t.Run("FileListener/SetUnlinkOnClose(false)", func(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("skipping: FileListener not implemented on windows")
+ }
l := listen(t)
f, _ := l.File()
l1, _ := FileListener(f)