1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-26 13:48:59 +08:00

Adding Slackware platform information

This commit is contained in:
Ozair Jr 2018-07-25 10:17:08 -03:00
parent d9d9688f3d
commit 0bab9611d2

View File

@ -319,6 +319,12 @@ func PlatformInformationWithContext(ctx context.Context) (platform string, famil
if err == nil {
version = getRedhatishVersion(contents)
}
} else if common.PathExists(common.HostEtc("slackware-version")) {
platform = "slackware"
contents, err := common.ReadLines(common.HostEtc("slackware-version"))
if err == nil {
version = getSlackwareVersion(contents)
}
} else if common.PathExists(common.HostEtc("debian_version")) {
if lsb.ID == "Ubuntu" {
platform = "ubuntu"
@ -441,6 +447,12 @@ func KernelVersionWithContext(ctx context.Context) (version string, err error) {
return version, nil
}
func getSlackwareVersion(contents []string) string {
c := strings.ToLower(strings.Join(contents, ""))
c = strings.Replace(c, "slackware ", "", 1)
return c
}
func getRedhatishVersion(contents []string) string {
c := strings.ToLower(strings.Join(contents, ""))