From 39db32c8fb9e128afbb4d5af29d090ce5df237f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Tegn=C3=A9r?= <johannes@jitesoft.com> Date: Tue, 10 Oct 2023 10:31:24 +0200 Subject: [PATCH] Created new 'env_windows' file. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 <johannes@jitesoft.com> --- pkg/env/env.go | 3 +++ pkg/env/env_windows.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 pkg/env/env_windows.go diff --git a/pkg/env/env.go b/pkg/env/env.go index c0674b842..bd836b3aa 100644 --- a/pkg/env/env.go +++ b/pkg/env/env.go @@ -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 ( diff --git a/pkg/env/env_windows.go b/pkg/env/env_windows.go new file mode 100644 index 000000000..0970d85ef --- /dev/null +++ b/pkg/env/env_windows.go @@ -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) +}