Skip to content

fix: hasBeegoRegex AND refactor: optimized code #710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down