Skip to content

Commit

Permalink
Created new 'env_windows' file.
Browse files Browse the repository at this point in the history
Conditionally compiled on windows targets and makes use of the
runtime.GOARCH and runtime.GOOS constants instead of executing uname to
get the arch and os.

Signed-off-by: Johannes Tegnér <[email protected]>
  • Loading branch information
Johannestegner committed Oct 23, 2023
1 parent 3b27f27 commit 39db32c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/env/env.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) arkade author(s) 2022. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

//go:build !windows
// +build !windows

package env

import (
Expand Down
31 changes: 31 additions & 0 deletions pkg/env/env_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) arkade author(s) 2022. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

//go:build windows
// +build windows

package env

import (
"os"
"path"
"runtime"
"strings"
)

// GetClientArch returns a pair of arch and os
func GetClientArch() (arch string, os string) {
arch = runtime.GOARCH
os = strings.ToLower(runtime.GOOS)
return arch, os
}

func LocalBinary(name, subdir string) string {
home := os.Getenv("HOME")
val := path.Join(home, ".arkade/bin/")
if len(subdir) > 0 {
val = path.Join(val, subdir)
}

return path.Join(val, name)
}

0 comments on commit 39db32c

Please sign in to comment.