gopsutil icon indicating copy to clipboard operation
gopsutil copied to clipboard

host.PlatformInformation() not precise on Ubuntu

Open the-hotmann opened this issue 1 year ago • 3 comments

When I get run:

_, _, host_version, _ := host.PlatformInformation()
fmt.Println(host_version)

On debian I get 11.9 while cat /etc/*release* just shows:

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Which means the tool is more precise than simple shell calls.

But on Ubuntu it gives me back 22.04 While cat /etc/*release* lets me exactly know that it is 22.04.4. I would like it to display the exact version - including the patch-version - on Ubuntu (22.04.4), not just the Major and Minir version.

I hope this is not too much to ask for :)

Thanks for this nice tool!

the-hotmann avatar Jun 10 '24 00:06 the-hotmann

The version likely comes from /etc/lsb-release, which doesn't contain the patch revision in a correct format for machines. Changing that output would also break any app that's looking for a specific version that suddenly includes a patch revision.

davidnewhall avatar Jul 11 '24 01:07 davidnewhall

same is true for windows build version. The information would be available from host.platformInformation() but that's not exported as public interface anywhere (anymore). v3 host.PlatformInformationWithContext() contained the build number. How can i access this information with v4?

sni avatar Jul 11 '24 10:07 sni

Sorry for the late reply.

  1. Agree with @davidnewhall, retrieving the patch version of Ubuntu would significantly break compatibility, so I believe a major version upgrade is necessary.

  2. As you mentioned, in the v4 major version upgrade, PlatformVersion() was changed from the Windows build version (e.g., 10.0.22631.3447) to something like 23H2. However, you can still obtain the build version using KernelVersion(). See #1629.

shirou avatar Jul 21 '24 08:07 shirou