mirror of
https://github.com/beego/bee.git
synced 2024-11-21 23:50:54 +00:00
bee new uses go mod by default
This commit is contained in:
parent
8ac965a433
commit
f3240109bf
@ -27,7 +27,7 @@ import (
|
|||||||
"github.com/beego/bee/utils"
|
"github.com/beego/bee/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var module utils.DocValue
|
var gopath utils.DocValue
|
||||||
var beegoVersion utils.DocValue
|
var beegoVersion utils.DocValue
|
||||||
|
|
||||||
var CmdNew = &commands.Command{
|
var CmdNew = &commands.Command{
|
||||||
@ -89,8 +89,7 @@ func init() {
|
|||||||
beego.Router("/", &controllers.MainController{})
|
beego.Router("/", &controllers.MainController{})
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
var goMod = `
|
var goMod = `module %s
|
||||||
module %s
|
|
||||||
|
|
||||||
go %s
|
go %s
|
||||||
|
|
||||||
@ -256,8 +255,8 @@ var reloadJsClient = `function b(a){var c=new WebSocket(a);c.onclose=function(){
|
|||||||
`
|
`
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
CmdNew.Flag.Var(&module, "module", "Support go modules")
|
CmdNew.Flag.Var(&gopath, "gopath", "Support go path")
|
||||||
CmdNew.Flag.Var(&beegoVersion, "beego", "set beego version,only take effect by -module=true")
|
CmdNew.Flag.Var(&beegoVersion, "beego", "set beego version,only take effect by module mod")
|
||||||
commands.AvailableCommands = append(commands.AvailableCommands, CmdNew)
|
commands.AvailableCommands = append(commands.AvailableCommands, CmdNew)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,14 +267,15 @@ func CreateApp(cmd *commands.Command, args []string) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(args) >= 2 {
|
if len(args) >= 2 {
|
||||||
cmd.Flag.Parse(args[1:])
|
err := cmd.Flag.Parse(args[1:])
|
||||||
} else {
|
if err != nil {
|
||||||
module = "false"
|
beeLogger.Log.Fatal("Parse args err " + err.Error())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var appPath string
|
var appPath string
|
||||||
var packPath string
|
var packPath string
|
||||||
var err error
|
var err error
|
||||||
if module != `true` {
|
if gopath == `true` {
|
||||||
beeLogger.Log.Info("generate new project support GOPATH")
|
beeLogger.Log.Info("generate new project support GOPATH")
|
||||||
version.ShowShortVersionBanner()
|
version.ShowShortVersionBanner()
|
||||||
appPath, packPath, err = utils.CheckEnv(args[0])
|
appPath, packPath, err = utils.CheckEnv(args[0])
|
||||||
@ -301,8 +301,13 @@ func CreateApp(cmd *commands.Command, args []string) int {
|
|||||||
|
|
||||||
beeLogger.Log.Info("Creating application...")
|
beeLogger.Log.Info("Creating application...")
|
||||||
|
|
||||||
|
// If it is the current directory, select the current folder name to package path
|
||||||
|
if packPath == "." {
|
||||||
|
packPath = path.Base(appPath)
|
||||||
|
}
|
||||||
|
|
||||||
os.MkdirAll(appPath, 0755)
|
os.MkdirAll(appPath, 0755)
|
||||||
if module == `true` {
|
if gopath != `true` {
|
||||||
fmt.Fprintf(output, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", path.Join(appPath, "go.mod"), "\x1b[0m")
|
fmt.Fprintf(output, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", path.Join(appPath, "go.mod"), "\x1b[0m")
|
||||||
utils.WriteToFile(path.Join(appPath, "go.mod"), fmt.Sprintf(goMod, packPath, utils.GetGoVersionSkipMinor(), beegoVersion.String()))
|
utils.WriteToFile(path.Join(appPath, "go.mod"), fmt.Sprintf(goMod, packPath, utils.GetGoVersionSkipMinor(), beegoVersion.String()))
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ var DefaultBeegoPro = &Container{
|
|||||||
Dsn: "",
|
Dsn: "",
|
||||||
Driver: "mysql",
|
Driver: "mysql",
|
||||||
ProType: "default",
|
ProType: "default",
|
||||||
ApiPrefix: "/",
|
ApiPrefix: "/api",
|
||||||
EnableModule: nil,
|
EnableModule: nil,
|
||||||
Models: make(map[string]TextModel, 0),
|
Models: make(map[string]TextModel, 0),
|
||||||
GitRemotePath: "https://github.com/beego-dev/beego-pro.git",
|
GitRemotePath: "https://github.com/beego-dev/beego-pro.git",
|
||||||
|
Loading…
Reference in New Issue
Block a user