From eb15d06a52f037f61a026a76e4baabc52c52809d Mon Sep 17 00:00:00 2001 From: Arturo Reuschenbach Puncernau Date: Mon, 3 Jun 2019 14:21:04 +0200 Subject: [PATCH] trim quotes when reading from os-release --- internal/common/common_linux.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/common/common_linux.go b/internal/common/common_linux.go index 1938b49..ea2860e 100644 --- a/internal/common/common_linux.go +++ b/internal/common/common_linux.go @@ -237,10 +237,20 @@ func GetOSRelease() (platform string, version string, err error) { } switch field[0] { case "ID": // use ID for lowercase - platform = field[1] + platform = trimQuotes(field[1]) case "VERSION": - version = field[1] + version = trimQuotes(field[1]) } } return platform, version, nil } + +// Remove quotes of the source string +func trimQuotes(s string) string { + if len(s) >= 2 { + if s[0] == '"' && s[len(s)-1] == '"' { + return s[1 : len(s)-1] + } + } + return s +}