Skip to content

Commit 4684988

Browse files
committed
Detect core version on Windows platforms
1 parent 10388a8 commit 4684988

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

goInfo_windows.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ func GetInfo() (GoInfoObject, error) {
2222
gio.Hostname, _ = os.Hostname()
2323
return gio, fmt.Errorf("getInfo: %s", err)
2424
}
25-
osStr := strings.Replace(out.String(), "\n", "", -1)
26-
osStr = strings.Replace(osStr, "\r\n", "", -1)
27-
tmp1 := strings.Index(osStr, "[Version")
28-
tmp2 := strings.Index(osStr, "]")
29-
var ver string
30-
if tmp1 == -1 || tmp2 == -1 {
31-
ver = "unknown"
32-
} else {
33-
ver = osStr[tmp1+9 : tmp2]
25+
ver := "unknown"
26+
outStr := out.String()
27+
if strings.Contains(outStr, "[") {
28+
parts := strings.Split(strings.ReplaceAll(outStr, "\r\n\t", ""), "[")
29+
if len(parts) >= 2 {
30+
x := parts[1]
31+
x = strings.Split(x, "]")[0]
32+
parts = strings.Split(x, " ")
33+
ver = parts[len(parts)-1]
34+
}
3435
}
3536
gio := GoInfoObject{Kernel: "windows", Core: ver, Platform: platform(), OS: "windows", GoOS: runtime.GOOS, CPUs: runtime.NumCPU()}
3637
gio.Hostname, _ = os.Hostname()

0 commit comments

Comments
 (0)