Debian Codegraph @

src/net/platform_unix_test.go

raw
1 // Copyright 2025 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build unix || js || wasip1
6
7 package net
8
9 import (
10 "os/exec"
11 "runtime"
12 "strconv"
13 )
14
15 var unixEnabledOnAIX bool
16
17 func init() {
18 if runtime.GOOS == "aix" {
19 // Unix network isn't properly working on AIX 7.2 with
20 // Technical Level < 2.
21 // The information is retrieved only once in this init()
22 // instead of everytime testableNetwork is called.
23 out, _ := exec.Command("oslevel", "-s").Output()
24 if len(out) >= len("7200-XX-ZZ-YYMM") { // AIX 7.2, Tech Level XX, Service Pack ZZ, date YYMM
25 aixVer := string(out[:4])
26 tl, _ := strconv.Atoi(string(out[5:7]))
27 unixEnabledOnAIX = aixVer > "7200" || (aixVer == "7200" && tl >= 2)
28 }
29 }
30 }
31
32 func supportsUnixSocket() bool {
33 switch runtime.GOOS {
34 case "android", "ios":
35 return false
36 case "aix":
37 return unixEnabledOnAIX
38 }
39 return true
40 }