Skip to content

Commit

Permalink
auto use first install version
Browse files Browse the repository at this point in the history
  • Loading branch information
PWZER committed Nov 19, 2024
1 parent 2b1c1c2 commit fc31ca8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ var installCmd = &cobra.Command{
if err := internal.Install(version); err != nil {
return err
}

if err := internal.UseIfNotLinkGoBin(version); err != nil {
return err
}
}
return nil
}
Expand Down
11 changes: 11 additions & 0 deletions internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ func UseGoVersion(version string) (err error) {
return nil
}

func UseIfNotLinkGoBin(version string) (err error) {
if !localVersionAlreadyInstalled(version) {
return fmt.Errorf("Local version %s not found", version)
}
goBin := getGoBinaryLinkFile()
if _, err = os.Stat(goBin); os.IsNotExist(err) {
return UseGoVersion(version)
}
return nil
}

func GetVersions(remote bool, all bool) (versions []*Version, err error) {
if remote {
return GetRemoteVersions(all)
Expand Down

0 comments on commit fc31ca8

Please sign in to comment.