mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
added Windows support.
Fixed build number and OS version for Windows. Signed-off-by: Mike Lloyd <mike@reboot3times.org>
This commit is contained in:
parent
bbdc860625
commit
7c03d607cb
34
system/system_info_windows.go
Normal file
34
system/system_info_windows.go
Normal file
@ -0,0 +1,34 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type SystemInfo struct {
|
||||
ProductName string
|
||||
ProductVersion string
|
||||
BuildVersion string
|
||||
}
|
||||
|
||||
func NewSystemInfo() *SystemInfo {
|
||||
m := make(map[string]string)
|
||||
|
||||
cmd := exec.Command("powershell.exe", "(Get-CimInstance Win32_OperatingSystem).version")
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s := strings.Split(string(out), ".")
|
||||
m["ProductName"] = "Windows"
|
||||
m["ProductVersion"] = "Windows " + s[0] + "." + s[1]
|
||||
m["BuildVersion"] = s[2]
|
||||
|
||||
sysInfo := SystemInfo{
|
||||
ProductName: m["ProductName"],
|
||||
ProductVersion: m["ProductVersion"],
|
||||
BuildVersion: m["BuildVersion"],
|
||||
}
|
||||
|
||||
return &sysInfo
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user