diff --git a/cli/meta/symlink_win.go b/cli/meta/symlink_win.go index 81304ea..62eb074 100644 --- a/cli/meta/symlink_win.go +++ b/cli/meta/symlink_win.go @@ -9,7 +9,6 @@ import ( // "bytes" "errors" "os" - "runtime" // "os/exec" "strings" @@ -54,15 +53,13 @@ func isAdmin() bool { func Symlink(oldname, newname string) error { // Check if already admin first - if runtime.GOOS == "windows" && isAdmin() { + if isAdmin() { if err := os.Symlink(oldname, newname); err != nil { return errors.Join(ErrEscalatedSymlink, err) } return nil - } - - // If not already admin, try to become admin - if runtime.GOOS == "windows" && !isAdmin() { + } else { + // If not already admin, try to become admin if err := becomeAdmin(); err != nil { if err := os.Symlink(oldname, newname); err != nil { return errors.Join(ErrEscalatedSymlink, err) @@ -70,5 +67,7 @@ func Symlink(oldname, newname string) error { } } + + return nil } diff --git a/cli/use.go b/cli/use.go index 6f5c11d..a2d3c68 100644 --- a/cli/use.go +++ b/cli/use.go @@ -8,6 +8,7 @@ import ( "bufio" "errors" "fmt" + "io/fs" "os" "path/filepath" "strings" @@ -40,8 +41,8 @@ func (z *ZVM) setBin(ver string) error { bin_dir := filepath.Join(z.baseDir, "bin") // Remove "bin" dir only if it already exists - _, err := os.Stat(bin_dir) - if !os.IsNotExist(err) { + + if _, err := os.Stat(bin_dir); errors.Is(err, fs.ErrExist) { fmt.Printf("Removing old %s", bin_dir) if err := os.Remove(bin_dir); err != nil { return err