platforms: Format(): use path.Join() instead of joinNotEmpty()

path.Join() also skips empty components, making it the equivalent of
this function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2021-08-02 09:48:34 +02:00
parent f12040b6b6
commit f2c3122e9c
2 changed files with 12 additions and 23 deletions

View File

@@ -107,6 +107,7 @@
package platforms
import (
"path"
"regexp"
"runtime"
"strconv"
@@ -246,20 +247,7 @@ func Format(platform specs.Platform) string {
return "unknown"
}
return joinNotEmpty(platform.OS, platform.Architecture, platform.Variant)
}
func joinNotEmpty(s ...string) string {
var ss []string
for _, s := range s {
if s == "" {
continue
}
ss = append(ss, s)
}
return strings.Join(ss, "/")
return path.Join(platform.OS, platform.Architecture, platform.Variant)
}
// Normalize validates and translate the platform to the canonical value.