func (c *AppConf) RunMode() string { if c.runMode != "" { return c.runMode } //1. check flag if mcore.IsHasDevArg() { c.runMode = MODE_DEV } else if mcore.IsHasProdArg() { c.runMode = "prod" } else if mcore.IsHasTestArg() { c.runMode = "test" } if c.runMode != "" { return c.runMode } // 2.check env if v := os.Getenv("RUN_MODE"); v != "" { c.runMode = v return c.runMode } // after all try, give default RunMode. if c.runMode == "" { c.runMode = MODE_DEV } return c.runMode }
// Demo demo func Demo() { fmt.Println("Hello Arg:", mcore.IsHasArg("hello")) fmt.Println("Dev Arg:", mcore.IsHasDevArg()) fmt.Println("Prod Arg:", mcore.IsHasProdArg()) }