From c0d118580967206d87b2d3e0adf9d36b08c6de38 Mon Sep 17 00:00:00 2001 From: Shirou WAKAYAMA Date: Mon, 6 Jun 2016 22:57:17 +0900 Subject: [PATCH] [host]linux: add alpine linux to detect host.Info(). --- host/host_linux.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/host/host_linux.go b/host/host_linux.go index 97924bf3..5c33cf4d 100644 --- a/host/host_linux.go +++ b/host/host_linux.go @@ -15,7 +15,7 @@ import ( "strings" "time" - "github.com/shirou/gopsutil/internal/common" + common "github.com/shirou/gopsutil/internal/common" ) type LSB struct { @@ -256,6 +256,12 @@ func PlatformInformation() (platform string, family string, version string, err } else if common.PathExists(common.HostEtc("arch-release")) { platform = "arch" version = lsb.Release + } else if common.PathExists(common.HostEtc("alpine-release")) { + platform = "alpine" + contents, err := common.ReadLines(common.HostEtc("alpine-release")) + if err == nil && len(contents) > 0 { + version = contents[0] + } } else if lsb.ID == "RedHat" { platform = "redhat" version = lsb.Release @@ -290,6 +296,8 @@ func PlatformInformation() (platform string, family string, version string, err family = "arch" case "exherbo": family = "exherbo" + case "alpine": + family = "alpine" } return platform, family, version, nil