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

fix Mac OS main.go:4:2: import "/Users/username/gopath/src/beegoApp/routers": cannot import absolute path

This commit is contained in:
zhangming 2014-06-30 21:12:29 +08:00
parent 47379b40a0
commit 58af77443b

23
new.go
View File

@ -89,7 +89,8 @@ func createApp(cmd *Command, args []string) {
os.Exit(2) os.Exit(2)
} }
apppath := path.Join(curpath, args[0]) appname = args[0]
apppath := path.Join(curpath, appname)
if _, err := os.Stat(apppath); os.IsNotExist(err) == false { if _, err := os.Stat(apppath); os.IsNotExist(err) == false {
fmt.Printf("[ERRO] Path(%s) has alreay existed\n", apppath) fmt.Printf("[ERRO] Path(%s) has alreay existed\n", apppath)
@ -123,20 +124,20 @@ func createApp(cmd *Command, args []string) {
fmt.Println(path.Join(apppath, "conf", "app.conf")) fmt.Println(path.Join(apppath, "conf", "app.conf"))
writetofile(path.Join(apppath, "conf", "app.conf"), strings.Replace(appconf, "{{.Appname}}", args[0], -1)) writetofile(path.Join(apppath, "conf", "app.conf"), strings.Replace(appconf, "{{.Appname}}", args[0], -1))
fmt.Println(path.Join(apppath, "controllers", "default.go")) fmt.Println(path.Join(appname, "controllers", "default.go"))
writetofile(path.Join(apppath, "controllers", "default.go"), controllers) writetofile(path.Join(appname, "controllers", "default.go"), controllers)
fmt.Println(path.Join(apppath, "views", "index.tpl")) fmt.Println(path.Join(appname, "views", "index.tpl"))
writetofile(path.Join(apppath, "views", "index.tpl"), indextpl) writetofile(path.Join(appname, "views", "index.tpl"), indextpl)
fmt.Println(path.Join(apppath, "routers", "router.go")) fmt.Println(path.Join(appname, "routers", "router.go"))
writetofile(path.Join(apppath, "routers", "router.go"), strings.Replace(router, "{{.Appname}}", strings.Join(strings.Split(apppath[len(appsrcpath)+1:], string(path.Separator)), "/"), -1)) writetofile(path.Join(appname, "routers", "router.go"), strings.Replace(router, "{{.Appname}}", strings.Join(strings.Split(appname[len(appsrcpath):], string(path.Separator)), "/"), -1))
fmt.Println(path.Join(apppath, "tests", "default_test.go")) fmt.Println(path.Join(appname, "tests", "default_test.go"))
writetofile(path.Join(apppath, "tests", "default_test.go"), strings.Replace(test, "{{.Appname}}", strings.Join(strings.Split(apppath[len(appsrcpath)+1:], string(path.Separator)), "/"), -1)) writetofile(path.Join(appname, "tests", "default_test.go"), strings.Replace(test, "{{.Appname}}", strings.Join(strings.Split(appname[len(appsrcpath):], string(path.Separator)), "/"), -1))
fmt.Println(path.Join(apppath, "main.go")) fmt.Println(path.Join(appname, "main.go"))
writetofile(path.Join(apppath, "main.go"), strings.Replace(maingo, "{{.Appname}}", strings.Join(strings.Split(apppath[len(appsrcpath)+1:], string(path.Separator)), "/"), -1)) writetofile(path.Join(appname, "main.go"), strings.Replace(maingo, "{{.Appname}}", strings.Join(strings.Split(appname[len(appsrcpath):], string(path.Separator)), "/"), -1))
ColorLog("[SUCC] New application successfully created!\n") ColorLog("[SUCC] New application successfully created!\n")
} }