From de6e732441fd90eabf406aef8cf4b10fe4ba93e5 Mon Sep 17 00:00:00 2001 From: xavierror Date: Thu, 6 Aug 2020 10:36:47 +0800 Subject: [PATCH 1/2] fix: hasBeegoRegex --- utils/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/utils.go b/utils/utils.go index eedd57a..2a29633 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -79,7 +79,7 @@ func IsInGOPATH(thePath string) bool { // IsBeegoProject checks whether the current path is a Beego application or not func IsBeegoProject(thePath string) bool { mainFiles := []string{} - hasBeegoRegex := regexp.MustCompile(`(?s)package main.*?import.*?\(.*?github.com/astaxie/beego".*?\).*func main()`) + hasBeegoRegex := regexp.MustCompile(`(?s)package main.*?import.*?\(.*?github.com/astaxie/beego".*?\).*func main\(\)`) c := make(chan error) // Walk the application path tree to look for main files. // Main files must satisfy the 'hasBeegoRegex' regular expression. From da530d986c1b0049b66d7d3234295a2e72e34845 Mon Sep 17 00:00:00 2001 From: xavierror Date: Thu, 6 Aug 2020 10:44:31 +0800 Subject: [PATCH 2/2] refactor: optimized code --- utils/utils.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/utils.go b/utils/utils.go index 2a29633..928f536 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -153,8 +153,10 @@ func AskForConfirmation() bool { if err != nil { beeLogger.Log.Fatalf("%s", err) } - okayResponses := []string{"y", "Y", "yes", "Yes", "YES"} - nokayResponses := []string{"n", "N", "no", "No", "NO"} + response = strings.ToLower(strings.TrimSpace(response)) + + okayResponses := []string{"y", "yes"} + nokayResponses := []string{"n", "no"} if containsString(okayResponses, response) { return true } else if containsString(nokayResponses, response) {