mirror of
				https://github.com/beego/bee.git
				synced 2025-11-03 23:03:27 +00:00 
			
		
		
		
	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.
This commit is contained in:
		
							
								
								
									
										8
									
								
								run.go
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								run.go
									
									
									
									
									
								
							@@ -87,7 +87,7 @@ func runApp(cmd *Command, args []string) int {
 | 
				
			|||||||
			currentGoPath = _gopath
 | 
								currentGoPath = _gopath
 | 
				
			||||||
			appname = path.Base(currpath)
 | 
								appname = path.Base(currpath)
 | 
				
			||||||
		} else {
 | 
							} 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)
 | 
							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)
 | 
						Debugf("current path:%s\n", currpath)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if runmode == "prod" || runmode == "dev"{
 | 
						if runmode == "prod" || runmode == "dev" {
 | 
				
			||||||
		os.Setenv("BEEGO_RUNMODE", runmode)
 | 
							os.Setenv("BEEGO_RUNMODE", runmode)
 | 
				
			||||||
		ColorLog("[INFO] Using '%s' as 'runmode'\n", os.Getenv("BEEGO_RUNMODE"))
 | 
							ColorLog("[INFO] Using '%s' as 'runmode'\n", os.Getenv("BEEGO_RUNMODE"))
 | 
				
			||||||
	}else if runmode != ""{
 | 
						} else if runmode != "" {
 | 
				
			||||||
		os.Setenv("BEEGO_RUNMODE", runmode)
 | 
							os.Setenv("BEEGO_RUNMODE", runmode)
 | 
				
			||||||
		ColorLog("[WARN] Using '%s' as 'runmode'\n", os.Getenv("BEEGO_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"))
 | 
							ColorLog("[WARN] Using '%s' as 'runmode'\n", os.Getenv("BEEGO_RUNMODE"))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user