Skip to content

Commit

Permalink
Fallback when last version retrieving fail (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvaumoron committed Jun 4, 2024
1 parent cc29fd8 commit bc8edce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 1 addition & 2 deletions cmd/go/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"io"
"net/http"
"net/url"
"os"
"runtime"
"strings"

Expand Down Expand Up @@ -101,7 +100,7 @@ func getLastVersion(conf config) versionDesc {

if err != nil || len(versions) == 0 {
fmt.Println("Unable to retrieve last version :", err)
os.Exit(1)
return versionDesc{}
}

datefile.Write(conf.dateFilePath)
Expand Down
8 changes: 7 additions & 1 deletion cmd/go/last.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ func main() {
installedVersion, versionMessage := getInstalledVersion(conf)
notInstalled := installedVersion == ""
if notInstalled || datefile.OutsideInterval(conf.dateFilePath, conf.checkInterval) {
if lastVersionDesc := getLastVersion(conf); installedVersion != lastVersionDesc.version {
if lastVersionDesc := getLastVersion(conf); lastVersionDesc.version == "" {
if notInstalled {
fmt.Println("Can not fallback, Go is not installed yet")
os.Exit(1)
}
fmt.Println("Fallback to", installedVersion, "already installed")
} else if installedVersion != lastVersionDesc.version {
doUpdate := true
if notInstalled {
fmt.Println("Install", lastVersionDesc.version)
Expand Down

0 comments on commit bc8edce

Please sign in to comment.