1
0
mirror of https://github.com/beego/bee.git synced 2024-11-21 23:50:54 +00:00

can't read bee.json from project so it always err

This commit is contained in:
astaxie 2013-07-30 15:35:39 +08:00
parent bf5f0baed7
commit 859c694ce7
2 changed files with 26 additions and 21 deletions

View File

@ -1,12 +0,0 @@
{
"go_install": false,
"dir_structure":{
"controllers": "",
"models": "",
"others": []
},
"main_files":{
"main.go": "",
"others": []
}
}

23
run.go
View File

@ -30,6 +30,21 @@ when the file has changed bee will auto go build and restart the app
`,
}
var defaultJson = `
{
"go_install": false,
"dir_structure":{
"controllers": "",
"models": "",
"others": []
},
"main_files":{
"main.go": "",
"others": []
}
}
`
func init() {
cmdRun.Run = runApp
}
@ -85,16 +100,18 @@ func loadConfig() error {
f, err := os.Open("bee.json")
if err != nil {
// Use default.
return nil
err = json.Unmarshal([]byte(defaultJson), &conf)
if err != nil {
return err
}
} else {
defer f.Close()
d := json.NewDecoder(f)
err = d.Decode(&conf)
if err != nil {
return err
}
}
// Set variables.
if len(conf.DirStruct.Controllers) == 0 {
conf.DirStruct.Controllers = "controllers"