gopsutil icon indicating copy to clipboard operation
gopsutil copied to clipboard

[RFC] `winver.exe` output as platform version for windows hosts

Open jxsl13 opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe.

Both strings: kernel version and platform version contain the exact same string.

It might make sense to change the platform version to the string that is output by winver.exe

which looks like this: Version 22H2 (Build 22621.1992)

Reference implementation: https://github.com/jxsl13/osfacts/blob/master/distro/distro_windows.go#L51

image

package main

import (
	"encoding/json"
	"fmt"
	"log"

	"github.com/shirou/gopsutil/v3/host"
)

func main() {
	info, err := host.Info()
	if err != nil {
		log.Fatalln(err)
	}

	data, _ := json.MarshalIndent(info, "", " ")
	fmt.Println(string(data))
}

Output

{
 "hostname": "windows-laptop",
 "uptime": 18048,
 "bootTime": 1691735912,
 "procs": 305,
 "os": "windows",
 "platform": "Microsoft Windows 11 Enterprise",
 "platformFamily": "Standalone Workstation",
 "platformVersion": "10.0.22621.1992 Build 22621.1992",
 "kernelVersion": "10.0.22621.1992 Build 22621.1992",
 "kernelArch": "x86_64",
 "virtualizationSystem": "",
 "virtualizationRole": "",
 "hostId": "12ba0ae0-383e-11ee-84a6-bbe395fdc6b9"
}

jxsl13 avatar Aug 11 '23 13:08 jxsl13