網上搜索出來的方案:
修改源碼
func TestBeegoInit(ap string) { /* path := filepath.Join(ap, "conf", "app.conf") os.Chdir(ap) InitBeegoBeforeTest(path) */ os.Setenv("BEEGO_RUNMODE", "test") appConfigPath = filepath.Join(ap, "conf", "app.conf") os.Chdir(ap) initBeforeHTTPRun() }
後來 乾脆不用beego的配置文件 本身寫配置文件本身配置,這樣本身能夠方便的控制,例如:
func initBeego(c conf.BeegoConfig) { beego.BConfig.RunMode = c.RunMode beego.BConfig.Listen.HTTPAddr = c.HTTPAddr beego.BConfig.Listen.HTTPPort = c.HTTPPort beego.BConfig.RunMode = c.RunMode beego.BConfig.WebConfig.AutoRender = c.AutoRender beego.BConfig.CopyRequestBody = true beego.BConfig.ServerName = "IceServer" }