diff --git a/cmd/build.go b/cmd/build.go index 17e63a57..2e0ad36e 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -388,7 +388,7 @@ func build(projectName string, targetOS string, vmArguments []string) { } if semver.Prerelease() != "" { - log.Infof("Upgrade 'go-flutter' to the latest release") + log.Infof("Upgrading 'go-flutter' to the latest release") // no buildBranch provided and currentTag isn't a release, // force update. (same behaviour as previous version of hover). err = upgradeGoFlutter(targetOS, engineCachePath) @@ -399,7 +399,7 @@ func build(projectName string, targetOS string, vmArguments []string) { } else { // when the buildBranch is empty and the currentTag is a release. // Check if the 'go-flutter' needs updates. - versioncheck.CheckFoGoFlutterUpdate(filepath.Join(wd, buildPath), currentTag) + versioncheck.CheckForGoFlutterUpdate(filepath.Join(wd, buildPath), currentTag) } } else { diff --git a/cmd/upgrade.go b/cmd/upgrade.go index b63feabe..15ca3a0e 100644 --- a/cmd/upgrade.go +++ b/cmd/upgrade.go @@ -64,9 +64,14 @@ func upgradeGoFlutter(targetOS string, engineCachePath string) (err error) { return } + if buildBranch == "" { + buildBranch = "@latest" + } + cmdGoGetU := exec.Command(goBin, "get", "-u", "github.com/go-flutter-desktop/go-flutter"+buildBranch) cmdGoGetU.Dir = filepath.Join(wd, buildPath) cmdGoGetU.Env = append(os.Environ(), + "GOPROXY=direct", // github.com/golang/go/issues/32955 (allows '/' in branch name) "GO111MODULE=on", "CGO_LDFLAGS="+cgoLdflags, ) @@ -75,11 +80,7 @@ func upgradeGoFlutter(targetOS string, engineCachePath string) (err error) { err = cmdGoGetU.Run() if err != nil { - versionName := buildBranch - if versionName == "" { - versionName = "latest" - } - log.Errorf("Updating go-flutter to %s version failed: %v", versionName, err) + log.Errorf("Updating go-flutter to %s version failed: %v", buildBranch, err) return } diff --git a/internal/versioncheck/version.go b/internal/versioncheck/version.go index 16fa1df0..1255a212 100644 --- a/internal/versioncheck/version.go +++ b/internal/versioncheck/version.go @@ -14,11 +14,11 @@ import ( "github.com/tcnksm/go-latest" ) -// CheckFoGoFlutterUpdate check the last 'go-flutter' timestamp we have cached +// CheckForGoFlutterUpdate check the last 'go-flutter' timestamp we have cached // for the current project. If the last update comes back to more than X days, // fetch the last Github release semver. If the Github semver is more recent // than the current one, display the update notice. -func CheckFoGoFlutterUpdate(goDirectoryPath string, currentTag string) { +func CheckForGoFlutterUpdate(goDirectoryPath string, currentTag string) { cachedGoFlutterCheckPath := filepath.Join(goDirectoryPath, ".last_goflutter_check") cachedGoFlutterCheckBytes, err := ioutil.ReadFile(cachedGoFlutterCheckPath) if err != nil && !os.IsNotExist(err) {