Skip to content

Commit

Permalink
Updated GetClientArch to use runtime package instead of uname checks.
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Tegnér <johannes@jitesoft.com>
  • Loading branch information
Johannestegner committed Oct 10, 2023
1 parent 3b27f27 commit 9a2adf1
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions pkg/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9a2adf1

Please sign in to comment.