From 814b7e75ed07e2e4ba1fc64cdad36ebddcb757e5 Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Thu, 7 Dec 2023 11:44:08 +0300 Subject: [PATCH] feat: use filepath for process version --- gobrew.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/gobrew.go b/gobrew.go index ede6d14..5a1c053 100644 --- a/gobrew.go +++ b/gobrew.go @@ -425,19 +425,15 @@ func (gb *GoBrew) existsVersion(version string) bool { // CurrentVersion get current version from symb link func (gb *GoBrew) CurrentVersion() string { - fp, err := filepath.EvalSymlinks(gb.currentBinDir) if err != nil { return "" } - version := strings.TrimSuffix(fp, strings.Join([]string{"go", "bin"}, string(os.PathSeparator))) - paths := strings.Split(version, string(os.PathSeparator)) - for i := len(paths) - 1; i >= 0; i-- { - version = paths[i] - if version != "" { - break - } + version := strings.TrimSuffix(fp, filepath.Join("go", "bin")) + version = filepath.Base(version) + if version == "." { + return "" } return version }