diff --git a/system/system_info.go b/system/system_info_darwin.go similarity index 100% rename from system/system_info.go rename to system/system_info_darwin.go diff --git a/system/system_info_windows.go b/system/system_info_windows.go new file mode 100644 index 00000000..5e354b6b --- /dev/null +++ b/system/system_info_windows.go @@ -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 +}