From e6529f4ebc46b73df2f4daf161ad3b5dfaa6e031 Mon Sep 17 00:00:00 2001 From: Jiri Appl Date: Fri, 28 Sep 2018 17:41:55 -0700 Subject: [PATCH] Add support to detect ARM variant on Windows ARM variant detection logic was authored originally with POSIX OS in mind. This change leaves POSIX code path unaltered and adds support to detect ARM variant on Windows by leveraging runtime.goarch. Signed-off-by: Jiri Appl --- platforms/cpuinfo.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/platforms/cpuinfo.go b/platforms/cpuinfo.go index a5c5ab42b..bf6476b64 100644 --- a/platforms/cpuinfo.go +++ b/platforms/cpuinfo.go @@ -74,6 +74,22 @@ func getCPUInfo(pattern string) (info string, err error) { } func getCPUVariant() string { + if runtime.GOOS == "windows" { + // Windows only supports v7 for ARM32 and v8 for ARM64 and so we can use + // runtime.GOARCH to determine the variants + var variant string + switch runtime.GOARCH { + case "arm64": + variant = "v8" + case "arm": + variant = "v7" + default: + variant = "unknown" + } + + return variant + } + variant, err := getCPUInfo("Cpu architecture") if err != nil { log.L.WithError(err).Error("failure getting variant")