Skip to content

Commit

Permalink
Detect core version on Windows platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhamlett committed Dec 4, 2024
1 parent 10388a8 commit 4684988
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions goInfo_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ func GetInfo() (GoInfoObject, error) {
gio.Hostname, _ = os.Hostname()
return gio, fmt.Errorf("getInfo: %s", err)
}
osStr := strings.Replace(out.String(), "\n", "", -1)
osStr = strings.Replace(osStr, "\r\n", "", -1)
tmp1 := strings.Index(osStr, "[Version")
tmp2 := strings.Index(osStr, "]")
var ver string
if tmp1 == -1 || tmp2 == -1 {
ver = "unknown"
} else {
ver = osStr[tmp1+9 : tmp2]
ver := "unknown"
outStr := out.String()
if strings.Contains(outStr, "[") {
parts := strings.Split(strings.ReplaceAll(outStr, "\r\n\t", ""), "[")
if len(parts) >= 2 {
x := parts[1]
x = strings.Split(x, "]")[0]
parts = strings.Split(x, " ")
ver = parts[len(parts)-1]
}
}
gio := GoInfoObject{Kernel: "windows", Core: ver, Platform: platform(), OS: "windows", GoOS: runtime.GOOS, CPUs: runtime.NumCPU()}
gio.Hostname, _ = os.Hostname()
Expand Down

0 comments on commit 4684988

Please sign in to comment.