mirror of
https://github.com/beego/bee.git
synced 2024-11-21 18:40:54 +00:00
can't read bee.json from project so it always err
This commit is contained in:
parent
bf5f0baed7
commit
859c694ce7
12
bee.json
12
bee.json
@ -1,12 +0,0 @@
|
||||
{
|
||||
"go_install": false,
|
||||
"dir_structure":{
|
||||
"controllers": "",
|
||||
"models": "",
|
||||
"others": []
|
||||
},
|
||||
"main_files":{
|
||||
"main.go": "",
|
||||
"others": []
|
||||
}
|
||||
}
|
35
run.go
35
run.go
@ -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
|
||||
}
|
||||
}
|
||||
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"
|
||||
|
Loading…
Reference in New Issue
Block a user