From 9a2adf1b7c7e3ead9dd154548e060205ebd976c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Tegn=C3=A9r?= Date: Tue, 10 Oct 2023 10:31:24 +0200 Subject: [PATCH] Updated GetClientArch to use runtime package instead of uname checks. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Johannes Tegnér --- pkg/env/env.go | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/pkg/env/env.go b/pkg/env/env.go index c0674b842..d794a6000 100644 --- a/pkg/env/env.go +++ b/pkg/env/env.go @@ -4,39 +4,26 @@ package env import ( - "context" - "log" "os" "path" + "runtime" "strings" - - execute "github.com/alexellis/go-execute/v2" ) // GetClientArch returns a pair of arch and os func GetClientArch() (arch string, os string) { - task := execute.ExecTask{ - Command: "uname", - Args: []string{"-m"}, - StreamStdio: false} - res, err := task.Execute(context.Background()) - if err != nil { - log.Println(err) - } + arch = runtime.GOARCH + os = strings.ToLower(runtime.GOOS) - archResult := strings.TrimSpace(res.Stdout) - - taskOS := execute.ExecTask{Command: "uname", - Args: []string{"-s"}, - StreamStdio: false} - resOS, errOS := taskOS.Execute(context.Background()) - if errOS != nil { - log.Println(errOS) + if arch == "arm" { + arch = "armv7l" } - osResult := strings.TrimSpace(resOS.Stdout) + if arch == "arm64" && os != "darwin" { + arch = "aarch64" + } - return archResult, osResult + return arch, runtime.GOOS } func LocalBinary(name, subdir string) string {