Skip to content

Commit

Permalink
feat: use filepath for process version
Browse files Browse the repository at this point in the history
  • Loading branch information
juev committed Dec 7, 2023
1 parent cf33539 commit 814b7e7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions gobrew.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 814b7e7

Please sign in to comment.