mirror of
https://github.com/beego/bee.git
synced 2024-11-23 01:30:55 +00:00
Fixed double GOPATH issue
Default Crawl GOPATH full path So we will achieve complete double GOPATH Ex: / XXX: / CCCC But just need to pick up: / CCCC
This commit is contained in:
parent
9069078ac0
commit
304e6cc0a4
39
apiapp.go
39
apiapp.go
@ -632,16 +632,18 @@ func createapi(cmd *Command, args []string) int {
|
||||
} else {
|
||||
os.Mkdir(path.Join(apppath, "models"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "models"))
|
||||
os.Mkdir(path.Join(apppath, "routers"), 0755)
|
||||
fmt.Println("create routers:", path.Join(apppath, "routers"))
|
||||
os.Mkdir(path.Join(apppath, "structures"), 0755)
|
||||
fmt.Println("create structures:", path.Join(apppath, "structures"))
|
||||
|
||||
fmt.Println("create controllers object_controller.go:", path.Join(apppath, "controllers", "object_controller.go"))
|
||||
os.Mkdir(path.Join(apppath, "routers"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "routers"))
|
||||
|
||||
os.Mkdir(path.Join(apppath, "structures"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "structures"))
|
||||
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "controllers", "object_controller.go"))
|
||||
WriteToFile(path.Join(apppath, "controllers", "object_controller.go"),
|
||||
strings.Replace(apiControllers, "{{.Appname}}", packpath, -1))
|
||||
|
||||
fmt.Println("create controllers user_controller.go:", path.Join(apppath, "controllers", "user_controller.go"))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "controllers", "user_controller.go"))
|
||||
WriteToFile(path.Join(apppath, "controllers", "user_controller.go"),
|
||||
strings.Replace(apiControllers2, "{{.Appname}}", packpath, -1))
|
||||
|
||||
@ -653,24 +655,24 @@ func createapi(cmd *Command, args []string) int {
|
||||
WriteToFile(path.Join(apppath, "routers", "router.go"),
|
||||
strings.Replace(apirouter, "{{.Appname}}", packpath, -1))
|
||||
|
||||
fmt.Println("create models object.go:", path.Join(apppath, "models", "object.go"))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "models", "object.go"))
|
||||
WriteToFile(path.Join(apppath, "models", "object.go"),
|
||||
strings.Replace(apiModels, "{{.Appname}}", packpath, -1))
|
||||
|
||||
fmt.Println("create models user.go:", path.Join(apppath, "models", "user.go"))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "models", "user.go"))
|
||||
WriteToFile(path.Join(apppath, "models", "user.go"),
|
||||
strings.Replace(apiModels2, "{{.Appname}}", packpath, -1))
|
||||
|
||||
fmt.Println("create structures user_structure.go:", path.Join(apppath, "structures", "user_structure.go"))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "structures", "user_structure.go"))
|
||||
WriteToFile(path.Join(apppath, "structures", "user_structure.go"), apistructures)
|
||||
|
||||
fmt.Println("create structures object_structure.go:", path.Join(apppath, "structures", "object_structure.go"))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "structures", "object_structure.go"))
|
||||
WriteToFile(path.Join(apppath, "structures", "object_structure.go"), apistructures2)
|
||||
|
||||
fmt.Println("create helpers user_helper.go:", path.Join(apppath, "helpers", "user_helper.go"))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "helpers", "user_helper.go"))
|
||||
WriteToFile(path.Join(apppath, "helpers", "user_helper.go"), "package helpers")
|
||||
|
||||
fmt.Println("create helpers object_helper.go:", path.Join(apppath, "helpers", "object_helper.go"))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "helpers", "object_helper.go"))
|
||||
WriteToFile(path.Join(apppath, "helpers", "object_helper.go"), "package helpers")
|
||||
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "docs", "doc.go"))
|
||||
@ -685,9 +687,16 @@ func createapi(cmd *Command, args []string) int {
|
||||
}
|
||||
|
||||
func checkEnv(appname string) (apppath, packpath string, err error) {
|
||||
gopath := os.Getenv("GOPATH")
|
||||
Debugf("gopath:%s", gopath)
|
||||
if gopath == "" {
|
||||
gopaths := GetGOPATHs()
|
||||
Debugf("gopath:%s", gopaths)
|
||||
gopath := ""
|
||||
|
||||
switch len(gopaths) {
|
||||
case 1:
|
||||
gopath = gopaths[0]
|
||||
case 2:
|
||||
gopath = gopaths[1]
|
||||
default:
|
||||
err = fmt.Errorf("you should set GOPATH in the env")
|
||||
return
|
||||
}
|
||||
|
2
fix.go
2
fix.go
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"io/ioutil"
|
||||
@ -8,7 +9,6 @@ import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var cmdFix = &Command{
|
||||
|
8
g.go
8
g.go
@ -94,11 +94,11 @@ func generateCode(cmd *Command, args []string) int {
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
gopath := os.Getenv("GOPATH")
|
||||
Debugf("gopath:%s", gopath)
|
||||
if gopath == "" {
|
||||
gopaths := GetGOPATHs()
|
||||
Debugf("gopath:%s", gopaths)
|
||||
if len(gopaths) == 0 {
|
||||
ColorLog("[ERRO] $GOPATH not found\n")
|
||||
ColorLog("[HINT] Set $GOPATH in your environment vairables\n")
|
||||
ColorLog("[HINT] Set $GOPATH in your environment variables\n")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
|
16
g_appcode.go
16
g_appcode.go
@ -1030,10 +1030,18 @@ func getFileName(tbName string) (filename string) {
|
||||
}
|
||||
|
||||
func getPackagePath(curpath string) (packpath string) {
|
||||
gopath := os.Getenv("GOPATH")
|
||||
Debugf("gopath:%s", gopath)
|
||||
if gopath == "" {
|
||||
ColorLog("[ERRO] you should set GOPATH in the env")
|
||||
gopaths := GetGOPATHs()
|
||||
Debugf("gopath:%s", gopaths)
|
||||
gopath := ""
|
||||
|
||||
switch len(gopaths) {
|
||||
case 1:
|
||||
gopath = gopaths[0]
|
||||
case 2:
|
||||
gopath = gopaths[1]
|
||||
default:
|
||||
ColorLog("[ERRO] $GOPATH not found\n")
|
||||
ColorLog("[HINT] Set $GOPATH in your environment variables\n")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
|
@ -15,10 +15,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// article
|
||||
|
18
g_docs.go
18
g_docs.go
@ -276,10 +276,22 @@ func analisyscontrollerPkg(localName, pkgpath string) {
|
||||
if pkgpath == "github.com/astaxie/beego" {
|
||||
return
|
||||
}
|
||||
gopath := os.Getenv("GOPATH")
|
||||
if gopath == "" {
|
||||
panic("please set gopath")
|
||||
|
||||
gopaths := GetGOPATHs()
|
||||
Debugf("gopath:%s", gopaths)
|
||||
gopath := ""
|
||||
|
||||
switch len(gopaths) {
|
||||
case 1:
|
||||
gopath = gopaths[0]
|
||||
case 2:
|
||||
gopath = gopaths[1]
|
||||
default:
|
||||
ColorLog("[ERRO] $GOPATH not found\n")
|
||||
ColorLog("[HINT] Set $GOPATH in your environment variables\n")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
pkgRealpath := ""
|
||||
|
||||
wgopath := filepath.SplitList(gopath)
|
||||
|
@ -1,10 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func generateModel(mname, fields, crupath string) {
|
||||
@ -30,7 +30,7 @@ func generateModel(mname, fields, crupath string) {
|
||||
defer f.Close()
|
||||
var content string
|
||||
if fields != "" {
|
||||
generateStructure(modelName,fields,crupath)
|
||||
generateStructure(modelName, fields, crupath)
|
||||
content = strings.Replace(CRUD_MODEL_TPL, "{{packageName}}", packageName, -1)
|
||||
pkgPath := getPackagePath(crupath)
|
||||
content = strings.Replace(content, "{{pkgPath}}", pkgPath, -1)
|
||||
|
@ -1,9 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// recipe
|
||||
|
10
migrate.go
10
migrate.go
@ -66,13 +66,15 @@ func runMigration(cmd *Command, args []string) int {
|
||||
|
||||
crupath, _ := os.Getwd()
|
||||
|
||||
gopath := os.Getenv("GOPATH")
|
||||
Debugf("gopath:%s", gopath)
|
||||
if gopath == "" {
|
||||
gopaths := GetGOPATHs()
|
||||
Debugf("gopath:%s", gopaths)
|
||||
|
||||
if len(gopaths) == 0 {
|
||||
ColorLog("[ERRO] $GOPATH not found\n")
|
||||
ColorLog("[HINT] Set $GOPATH in your environment vairables\n")
|
||||
ColorLog("[HINT] Set $GOPATH in your environment variables\n")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
// load config
|
||||
err := loadConfig()
|
||||
if err != nil {
|
||||
|
39
new.go
39
new.go
@ -65,9 +65,16 @@ func createApp(cmd *Command, args []string) int {
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
gopath := os.Getenv("GOPATH")
|
||||
Debugf("gopath:%s", gopath)
|
||||
if gopath == "" {
|
||||
gopaths := GetGOPATHs()
|
||||
Debugf("gopath:%s", gopaths)
|
||||
gopath := ""
|
||||
|
||||
switch len(gopaths) {
|
||||
case 1:
|
||||
gopath = gopaths[0]
|
||||
case 2:
|
||||
gopath = gopaths[1]
|
||||
default:
|
||||
ColorLog("[ERRO] $GOPATH not found\n")
|
||||
ColorLog("[HINT] Set $GOPATH in your environment variables\n")
|
||||
os.Exit(2)
|
||||
@ -87,42 +94,42 @@ func createApp(cmd *Command, args []string) int {
|
||||
ColorLog("[INFO] Creating application...\n")
|
||||
|
||||
os.MkdirAll(apppath, 0755)
|
||||
fmt.Println("\tcreate\t", apppath + string(path.Separator))
|
||||
fmt.Println("\tcreate\t", apppath+string(path.Separator))
|
||||
|
||||
os.Mkdir(path.Join(apppath, "conf"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "conf") + string(path.Separator))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "conf")+string(path.Separator))
|
||||
|
||||
os.Mkdir(path.Join(apppath, "controllers"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "controllers") + string(path.Separator))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "controllers")+string(path.Separator))
|
||||
|
||||
os.Mkdir(path.Join(apppath, "helpers"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "helpers") + string(path.Separator))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "helpers")+string(path.Separator))
|
||||
|
||||
os.Mkdir(path.Join(apppath, "models"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "models") + string(path.Separator))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "models")+string(path.Separator))
|
||||
|
||||
os.Mkdir(path.Join(apppath, "routers"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "routers") + string(path.Separator))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "routers")+string(path.Separator))
|
||||
|
||||
os.Mkdir(path.Join(apppath, "tests"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "tests") + string(path.Separator))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "tests")+string(path.Separator))
|
||||
|
||||
os.Mkdir(path.Join(apppath, "structures"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "structures") + string(path.Separator))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "structures")+string(path.Separator))
|
||||
|
||||
os.Mkdir(path.Join(apppath, "static"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "static") + string(path.Separator))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "static")+string(path.Separator))
|
||||
|
||||
os.Mkdir(path.Join(apppath, "static", "js"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "static", "js") + string(path.Separator))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "static", "js")+string(path.Separator))
|
||||
|
||||
os.Mkdir(path.Join(apppath, "static", "css"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "static", "css") + string(path.Separator))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "static", "css")+string(path.Separator))
|
||||
|
||||
os.Mkdir(path.Join(apppath, "static", "img"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "static", "img") + string(path.Separator))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "static", "img")+string(path.Separator))
|
||||
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "views") + string(path.Separator))
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "views")+string(path.Separator))
|
||||
|
||||
os.Mkdir(path.Join(apppath, "views"), 0755)
|
||||
fmt.Println("\tcreate\t", path.Join(apppath, "conf", "app.conf"))
|
||||
|
@ -2,12 +2,12 @@ package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
path "path/filepath"
|
||||
"regexp"
|
||||
"bytes"
|
||||
)
|
||||
|
||||
var cmdVersion = &Command{
|
||||
@ -24,8 +24,7 @@ bee version
|
||||
`,
|
||||
}
|
||||
|
||||
const verboseVersionBanner =
|
||||
`______
|
||||
const verboseVersionBanner = `______
|
||||
| ___ \
|
||||
| |_/ / ___ ___
|
||||
| ___ \ / _ \ / _ \
|
||||
@ -43,8 +42,7 @@ Compiler : {{ .Compiler }}
|
||||
Date : {{ Now "Monday, 2 Jan 2006" }}
|
||||
`
|
||||
|
||||
const shortVersionBanner =
|
||||
`______
|
||||
const shortVersionBanner = `______
|
||||
| ___ \
|
||||
| |_/ / ___ ___
|
||||
| ___ \ / _ \ / _ \
|
||||
|
Loading…
Reference in New Issue
Block a user