1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/system/system_info_windows.go
Mike Lloyd 7c03d607cb added Windows support.
Fixed build number and OS version for Windows.

Signed-off-by: Mike Lloyd <mike@reboot3times.org>
2018-06-03 22:55:00 -06:00

35 lines
670 B
Go

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
}