Skip to content

Commit

Permalink
Improve ARCH detection for x86_64
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosnils committed Jun 2, 2020
1 parent 66197bc commit d610007
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 10 additions & 4 deletions pkg/config/config.go
Expand Up @@ -92,12 +92,18 @@ func write() error {

// GetArch is the running program's operating system target:
// one of darwin, freebsd, linux, and so on.
func GetArch() string {
return runtime.GOARCH
func GetArch() []string {
res := []string{runtime.GOARCH}
if runtime.GOARCH == "amd64" {
//Adding x86_64 manually since the uname syscall (man 2 uname)
//is not implemented in all systems
res = append(res, "x86_64")
}
return res
}

// GetOS is the running program's architecture target:
// one of 386, amd64, arm, s390x, and so on.
func GetOS() string {
return runtime.GOOS
func GetOS() []string {
return []string{runtime.GOOS}
}
3 changes: 2 additions & 1 deletion pkg/providers/github.go
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/apex/log"
"github.com/google/go-github/v31/github"
"github.com/marcosnils/bin/pkg/config"
bstrings "github.com/marcosnils/bin/pkg/strings"
)

type gitHub struct {
Expand Down Expand Up @@ -43,7 +44,7 @@ func (g *gitHub) Fetch() (*File, error) {
var f *File
for _, a := range release.Assets {
lowerName := strings.ToLower(*a.Name)
if strings.Contains(lowerName, config.GetOS()) && strings.Contains(lowerName, config.GetArch()) {
if bstrings.ContainsAny(lowerName, config.GetOS()) && bstrings.ContainsAny(lowerName, config.GetArch()) {
// We're not closing the body here since the caller is in charge of that
res, err := http.Get(*a.BrowserDownloadURL)
log.Debugf("Checking binary form %s", *a.BrowserDownloadURL)
Expand Down

0 comments on commit d610007

Please sign in to comment.