github.com/wtfutil/wtf@v0.43.0/modules/system/system_info_windows.go (about) 1 //go:build windows 2 3 package system 4 5 import ( 6 "os/exec" 7 "strings" 8 ) 9 10 type SystemInfo struct { 11 ProductName string 12 ProductVersion string 13 BuildVersion string 14 } 15 16 func NewSystemInfo() *SystemInfo { 17 m := make(map[string]string) 18 19 cmd := exec.Command("powershell.exe", "(Get-CimInstance Win32_OperatingSystem).version") 20 out, err := cmd.Output() 21 if err != nil { 22 panic(err) 23 } 24 s := strings.Split(string(out), ".") 25 m["ProductName"] = "Windows" 26 m["ProductVersion"] = "Windows " + s[0] + "." + s[1] 27 m["BuildVersion"] = s[2] 28 29 sysInfo := SystemInfo{ 30 ProductName: m["ProductName"], 31 ProductVersion: m["ProductVersion"], 32 BuildVersion: m["BuildVersion"], 33 } 34 35 return &sysInfo 36 }