mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
cmd/version: print os/version, kernel and bitness (#5204)
Related to #5121 Note: OpenBSD is stub yet. This will be fixed after upstream PR gets resolved https://github.com/shirou/gopsutil/pull/993
This commit is contained in:
34
lib/buildinfo/osversion.go
Normal file
34
lib/buildinfo/osversion.go
Normal file
@@ -0,0 +1,34 @@
|
||||
// +build !openbsd,!windows
|
||||
|
||||
package buildinfo
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/shirou/gopsutil/v3/host"
|
||||
)
|
||||
|
||||
// GetOSVersion returns OS version, kernel and bitness
|
||||
func GetOSVersion() (osVersion, osKernel string) {
|
||||
if platform, _, version, err := host.PlatformInformation(); err == nil && platform != "" {
|
||||
osVersion = platform
|
||||
if version != "" {
|
||||
osVersion += " " + version
|
||||
}
|
||||
}
|
||||
|
||||
if version, err := host.KernelVersion(); err == nil && version != "" {
|
||||
osKernel = version
|
||||
}
|
||||
|
||||
if arch, err := host.KernelArch(); err == nil && arch != "" {
|
||||
if strings.HasSuffix(arch, "64") && osVersion != "" {
|
||||
osVersion += " (64 bit)"
|
||||
}
|
||||
if osKernel != "" {
|
||||
osKernel += " (" + arch + ")"
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user