From 56568f4d2c60703d10b3bfb4e7326a9a6244a639 Mon Sep 17 00:00:00 2001 From: Faissal Elamraoui Date: Mon, 26 Sep 2016 20:32:14 +0200 Subject: [PATCH] tweak: Exit with message instead of a panic In case no application is found in GOPATH(s), exit with a friendly message instead of a panic. Also removed useless else block in watch.go. --- run.go | 8 ++++---- watch.go | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/run.go b/run.go index 8aab6b5..b84e199 100644 --- a/run.go +++ b/run.go @@ -87,7 +87,7 @@ func runApp(cmd *Command, args []string) int { currentGoPath = _gopath appname = path.Base(currpath) } else { - panic(fmt.Sprintf("No Beego application '%s' found in your GOPATH", args[0])) + exitPrint(fmt.Sprintf("No Beego application '%s' found in your GOPATH", args[0])) } ColorLog("[INFO] Using '%s' as 'appname'\n", appname) @@ -103,13 +103,13 @@ func runApp(cmd *Command, args []string) int { Debugf("current path:%s\n", currpath) - if runmode == "prod" || runmode == "dev"{ + if runmode == "prod" || runmode == "dev" { os.Setenv("BEEGO_RUNMODE", runmode) ColorLog("[INFO] Using '%s' as 'runmode'\n", os.Getenv("BEEGO_RUNMODE")) - }else if runmode != ""{ + } else if runmode != "" { os.Setenv("BEEGO_RUNMODE", runmode) ColorLog("[WARN] Using '%s' as 'runmode'\n", os.Getenv("BEEGO_RUNMODE")) - }else if os.Getenv("BEEGO_RUNMODE") != ""{ + } else if os.Getenv("BEEGO_RUNMODE") != "" { ColorLog("[WARN] Using '%s' as 'runmode'\n", os.Getenv("BEEGO_RUNMODE")) } diff --git a/watch.go b/watch.go index efde48a..1c8f593 100644 --- a/watch.go +++ b/watch.go @@ -240,9 +240,8 @@ func shouldIgnoreFile(filename string) bool { } if r.MatchString(filename) { return true - } else { - continue } + continue } return false }