From ab854cc8749dac6070117af45fa33c7ff70aebff Mon Sep 17 00:00:00 2001 From: LiuYang Date: Tue, 8 Jan 2019 12:04:02 +0800 Subject: [PATCH 01/16] Update g_docs.go bug fix --- generate/swaggergen/g_docs.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 71c13bd..fe3a08d 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -730,7 +730,7 @@ func parserComments(f *ast.FuncDecl, controllerName, pkgpath string) error { } } } - + routerPath = urlReplace(routerPath) if routerPath != "" { //Go over function parameters which were not mapped and create swagger params for them for name, typ := range funcParamMap { @@ -1198,7 +1198,7 @@ func parseStruct(st *ast.StructType, k string, m *swagger.Schema, realTypes *[]s for _, pkg := range astPkgs { for _, fl := range pkg.Files { for nameOfObj, obj := range fl.Scope.Objects { - if obj.Name == fmt.Sprint(field.Type) { + if pkg.Name+"."+obj.Name == realType { parseObject(obj, nameOfObj, nm, realTypes, astPkgs, pkg.Name) } } From 9433a7b66f3f3edd28d3417916b6c4f5095f9492 Mon Sep 17 00:00:00 2001 From: qiantao Date: Thu, 25 Jun 2020 22:29:27 +0800 Subject: [PATCH 02/16] =?UTF-8?q?1.=20new,api,hprose=20=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=A4=E4=B8=AA=E5=8F=82=E6=95=B0=20[-modu?= =?UTF-8?q?le=3Dtrue]=20[-beego=3Dv1.12.1]=20=E7=94=A8=E4=BA=8E=E7=94=9F?= =?UTF-8?q?=E6=88=90go=20module=E9=A1=B9=E7=9B=AE=202.=20generate,migrate?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E4=B8=8D=E5=86=8D=E6=89=93=E5=8D=B0GOPATH.?= =?UTF-8?q?=203.=20pack=E5=91=BD=E4=BB=A4=E6=8E=92=E9=99=A4=E3=80=82=204.?= =?UTF-8?q?=20run=E5=91=BD=E4=BB=A4=E6=94=AF=E6=8C=81=E4=BC=A0=E9=80=92ldf?= =?UTF-8?q?lags=E5=8F=82=E6=95=B0=205.=20fix=20watch=20file=20bug.ignoredF?= =?UTF-8?q?ilesRegExps=E6=95=B0=E7=BB=84=E5=AF=B9=E6=AF=8F=E4=B8=AA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A2=9E=E5=8A=A0$,=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E5=AD=98=E5=9C=A8tmp=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5=206.=20getPackagePath=E5=87=BD=E6=95=B0=E8=A2=AB?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=97=B6=E5=A6=82=E6=9E=9C=E6=89=BE=E4=B8=8D?= =?UTF-8?q?=E5=88=B0GOPATH=EF=BC=8C=E5=88=99=E7=9C=8B=E7=9C=8B=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B=E6=9C=89=E6=B2=A1=E6=9C=89go.mod=20=E6=9C=89=E5=B0=B1?= =?UTF-8?q?=E5=BD=93=E5=81=9Ago=20module=E9=A1=B9=E7=9B=AE=E5=A4=84?= =?UTF-8?q?=E7=90=86=E3=80=82=207.=20.travis.yml=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=97=B6=E6=8E=92=E9=99=A4/pkg/mod/=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 19 ++++++----- cmd/commands/api/apiapp.go | 53 +++++++++++++++++++++++++--- cmd/commands/generate/generate.go | 9 ----- cmd/commands/hprose/hprose.go | 57 +++++++++++++++++++++++++++---- cmd/commands/migrate/migrate.go | 9 ----- cmd/commands/new/new.go | 53 +++++++++++++++++++++++----- cmd/commands/pack/pack.go | 11 ++++-- cmd/commands/run/run.go | 3 ++ cmd/commands/run/watch.go | 13 ++++--- cmd/commands/version/version.go | 2 +- generate/g_appcode.go | 37 ++++++++++++++++++-- generate/swaggergen/g_docs.go | 34 ++++++++++-------- utils/utils.go | 9 +++++ 13 files changed, 237 insertions(+), 72 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0480311..eaad43e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,21 @@ language: go go: - - 1.10.3 + - 1.12.17 install: - export PATH=$PATH:$HOME/gopath/bin - go get -u github.com/opennota/check/cmd/structcheck - - go get -u honnef.co/go/tools/cmd/gosimple - go get -u honnef.co/go/tools/cmd/staticcheck - - go get -u honnef.co/go/tools/cmd/unused - go get -u github.com/mdempsky/unconvert - go get -u github.com/gordonklaus/ineffassign script: + - pwd + - cd $(dirname `dirname $(pwd)`)/beego/bee + - export GO111MODULE="on" + - go mod download - find . ! \( -path './vendor' -prune \) -type f -name '*.go' -print0 | xargs -0 gofmt -l -s - - go vet $(go list ./... | grep -v /vendor/) - - structcheck $(go list ./... | grep -v /vendor/) - - gosimple -ignore "$(cat gosimple.ignore)" $(go list ./... | grep -v /vendor/) - - staticcheck -ignore "$(cat staticcheck.ignore)" $(go list ./... | grep -v /vendor/) - - unused $(go list ./... | grep -v /vendor/) - - unconvert $(go list ./... | grep -v /vendor/) + - go list ./... | grep -v /vendor/ | grep -v /pkg/mod/ + - go vet $(go list ./... | grep -v /vendor/ | grep -v /pkg/mod/ ) + - structcheck $(go list ./... | grep -v /vendor/ | grep -v /pkg/mod/ ) + - staticcheck $(go list ./... | grep -v /vendor/ | grep -v /pkg/mod/ ) + - unconvert $(go list ./... | grep -v /vendor/ | grep -v /pkg/mod/ ) - ineffassign . diff --git a/cmd/commands/api/apiapp.go b/cmd/commands/api/apiapp.go index 8f9865f..1265329 100644 --- a/cmd/commands/api/apiapp.go +++ b/cmd/commands/api/apiapp.go @@ -16,8 +16,10 @@ package apiapp import ( "fmt" + "github.com/beego/bee/logger/colors" "os" path "path/filepath" + "runtime" "strings" "github.com/beego/bee/cmd/commands" @@ -35,7 +37,7 @@ var CmdApiapp = &commands.Command{ The command 'api' creates a Beego API application. {{"Example:"|bold}} - $ bee api [appname] [-tables=""] [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"] + $ bee api [appname] [-tables=""] [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"] [-module=true] [-beego=v1.12.1] If 'conn' argument is empty, the command will generate an example API application. Otherwise the command will connect to your database and generate models based on the existing tables. @@ -43,6 +45,7 @@ var CmdApiapp = &commands.Command{ The command 'api' creates a folder named [appname] with the following structure: ├── main.go + ├── go.mod ├── {{"conf"|foldername}} │ └── app.conf ├── {{"controllers"|foldername}} @@ -103,6 +106,14 @@ func main() { beego.Run() } +` +var goMod = ` +module %s + +go %s + +require github.com/astaxie/beego %s +require github.com/smartystreets/goconvey v1.6.4 ` var apirouter = `// @APIVersion 1.0.0 @@ -533,11 +544,15 @@ func TestGet(t *testing.T) { } ` +var module utils.DocValue +var beegoVersion utils.DocValue func init() { CmdApiapp.Flag.Var(&generate.Tables, "tables", "List of table names separated by a comma.") CmdApiapp.Flag.Var(&generate.SQLDriver, "driver", "Database driver. Either mysql, postgres or sqlite.") CmdApiapp.Flag.Var(&generate.SQLConn, "conn", "Connection string used by the driver to connect to a database instance.") + CmdApiapp.Flag.Var(&module, "module", "Support go modules") + CmdApiapp.Flag.Var(&beegoVersion, "beego", "set beego version,only take effect by -module=true") commands.AvailableCommands = append(commands.AvailableCommands, CmdApiapp) } @@ -548,14 +563,38 @@ func createAPI(cmd *commands.Command, args []string) int { beeLogger.Log.Fatal("Argument [appname] is missing") } - if len(args) > 1 { - err := cmd.Flag.Parse(args[1:]) + if len(args) >= 2 { + cmd.Flag.Parse(args[1:]) + } else { + module = "false" + } + var appPath string + var packPath string + var err error + if module != `true` { + beeLogger.Log.Info("generate api project support GOPATH") + version.ShowShortVersionBanner() + appPath, packPath, err = utils.CheckEnv(args[0]) if err != nil { - beeLogger.Log.Error(err.Error()) + beeLogger.Log.Fatalf("%s", err) + } + } else { + beeLogger.Log.Info("generate api project support go modules.") + appPath = path.Join(utils.GetBeeWorkPath(), args[0]) + packPath = args[0] + if beegoVersion.String() == `` { + beegoVersion.Set(`v1.12.1`) + } + } + + if utils.IsExist(appPath) { + beeLogger.Log.Errorf(colors.Bold("Application '%s' already exists"), appPath) + beeLogger.Log.Warn(colors.Bold("Do you want to overwrite it? [Yes|No] ")) + if !utils.AskForConfirmation() { + os.Exit(2) } } - appPath, packPath, err := utils.CheckEnv(args[0]) appName := path.Base(args[0]) if err != nil { beeLogger.Log.Fatalf("%s", err) @@ -567,6 +606,10 @@ func createAPI(cmd *commands.Command, args []string) int { beeLogger.Log.Info("Creating API...") os.MkdirAll(appPath, 0755) + if module == `true` { //generate first for calc model name + 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, runtime.Version()[2:], beegoVersion.String())) + } fmt.Fprintf(output, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", appPath, "\x1b[0m") os.Mkdir(path.Join(appPath, "conf"), 0755) fmt.Fprintf(output, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", path.Join(appPath, "conf"), "\x1b[0m") diff --git a/cmd/commands/generate/generate.go b/cmd/commands/generate/generate.go index 993ff3f..d8bee28 100644 --- a/cmd/commands/generate/generate.go +++ b/cmd/commands/generate/generate.go @@ -81,15 +81,6 @@ func GenerateCode(cmd *commands.Command, args []string) int { beeLogger.Log.Fatal("Command is missing") } - gps := utils.GetGOPATHs() - if len(gps) == 0 { - beeLogger.Log.Fatal("GOPATH environment variable is not set or empty") - } - - gopath := gps[0] - - beeLogger.Log.Debugf("GOPATH: %s", utils.FILE(), utils.LINE(), gopath) - gcmd := args[0] switch gcmd { case "scaffold": diff --git a/cmd/commands/hprose/hprose.go b/cmd/commands/hprose/hprose.go index 1d50581..f926c53 100644 --- a/cmd/commands/hprose/hprose.go +++ b/cmd/commands/hprose/hprose.go @@ -1,7 +1,9 @@ package hprose import ( + "github.com/beego/bee/logger/colors" "os" + "runtime" "fmt" "path" @@ -24,7 +26,7 @@ var CmdHproseapp = &commands.Command{ {{"To scaffold out your application, use:"|bold}} - $ bee hprose [appname] [-tables=""] [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"] + $ bee hprose [appname] [-tables=""] [-driver=mysql] [-conn="root:@tcp(127.0.0.1:3306)/test"] [-module=true] [-beego=v1.12.1] If 'conn' is empty, the command will generate a sample application. Otherwise the command will connect to your database and generate models based on the existing tables. @@ -32,6 +34,7 @@ var CmdHproseapp = &commands.Command{ The command 'hprose' creates a folder named [appname] with the following structure: ├── main.go + ├── go.mod ├── {{"conf"|foldername}} │ └── app.conf └── {{"models"|foldername}} @@ -42,34 +45,76 @@ var CmdHproseapp = &commands.Command{ Run: createhprose, } +var goMod = ` +module %s + +go %s + +require github.com/astaxie/beego %s +require github.com/smartystreets/goconvey v1.6.4 +` + +var module utils.DocValue +var beegoVersion utils.DocValue + func init() { CmdHproseapp.Flag.Var(&generate.Tables, "tables", "List of table names separated by a comma.") CmdHproseapp.Flag.Var(&generate.SQLDriver, "driver", "Database driver. Either mysql, postgres or sqlite.") CmdHproseapp.Flag.Var(&generate.SQLConn, "conn", "Connection string used by the driver to connect to a database instance.") + CmdHproseapp.Flag.Var(&module, "module", "Support go modules") + CmdHproseapp.Flag.Var(&beegoVersion, "beego", "set beego version,only take effect by -module=true") commands.AvailableCommands = append(commands.AvailableCommands, CmdHproseapp) } func createhprose(cmd *commands.Command, args []string) int { output := cmd.Out() - - if len(args) != 1 { + if len(args) == 0 { beeLogger.Log.Fatal("Argument [appname] is missing") } curpath, _ := os.Getwd() if len(args) > 1 { cmd.Flag.Parse(args[1:]) + } else { + module = "false" } - apppath, packpath, err := utils.CheckEnv(args[0]) - if err != nil { - beeLogger.Log.Fatalf("%s", err) + var apppath string + var packpath string + var err error + if module != `true` { + beeLogger.Log.Info("generate api project support GOPATH") + version.ShowShortVersionBanner() + apppath, packpath, err = utils.CheckEnv(args[0]) + if err != nil { + beeLogger.Log.Fatalf("%s", err) + } + } else { + beeLogger.Log.Info("generate api project support go modules.") + apppath = path.Join(utils.GetBeeWorkPath(), args[0]) + packpath = args[0] + if beegoVersion.String() == `` { + beegoVersion.Set(`v1.12.1`) + } } + + if utils.IsExist(apppath) { + beeLogger.Log.Errorf(colors.Bold("Application '%s' already exists"), apppath) + beeLogger.Log.Warn(colors.Bold("Do you want to overwrite it? [Yes|No] ")) + if !utils.AskForConfirmation() { + os.Exit(2) + } + } + if generate.SQLDriver == "" { generate.SQLDriver = "mysql" } beeLogger.Log.Info("Creating Hprose application...") os.MkdirAll(apppath, 0755) + if module == `true` { //generate first for calc model name + 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, runtime.Version()[2:], beegoVersion.String())) + } fmt.Fprintf(output, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", apppath, "\x1b[0m") os.Mkdir(path.Join(apppath, "conf"), 0755) fmt.Fprintf(output, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", path.Join(apppath, "conf"), "\x1b[0m") diff --git a/cmd/commands/migrate/migrate.go b/cmd/commands/migrate/migrate.go index 71e93cd..edf6bbb 100644 --- a/cmd/commands/migrate/migrate.go +++ b/cmd/commands/migrate/migrate.go @@ -71,15 +71,6 @@ func init() { func RunMigration(cmd *commands.Command, args []string) int { currpath, _ := os.Getwd() - gps := utils.GetGOPATHs() - if len(gps) == 0 { - beeLogger.Log.Fatal("GOPATH environment variable is not set or empty") - } - - gopath := gps[0] - - beeLogger.Log.Debugf("GOPATH: %s", utils.FILE(), utils.LINE(), gopath) - // Getting command line arguments if len(args) != 0 { cmd.Flag.Parse(args[1:]) diff --git a/cmd/commands/new/new.go b/cmd/commands/new/new.go index 3cb1cc7..98c1aed 100644 --- a/cmd/commands/new/new.go +++ b/cmd/commands/new/new.go @@ -18,6 +18,7 @@ import ( "fmt" "os" path "path/filepath" + "runtime" "strings" "github.com/beego/bee/cmd/commands" @@ -27,15 +28,19 @@ import ( "github.com/beego/bee/utils" ) +var module utils.DocValue +var beegoVersion utils.DocValue + var CmdNew = &commands.Command{ - UsageLine: "new [appname]", + UsageLine: "new [appname] [-module=true] [-beego=v1.12.1]", Short: "Creates a Beego application", Long: ` Creates a Beego application for the given app name in the current directory. - - The command 'new' creates a folder named [appname] and generates the following structure: + now supoort generate a go modules project + The command 'new' creates a folder named [appname] [-module=true] [-beego=v1.12.1] and generates the following structure: ├── main.go + ├── go.mod ├── {{"conf"|foldername}} │ └── app.conf ├── {{"controllers"|foldername}} @@ -53,7 +58,7 @@ Creates a Beego application for the given app name in the current directory. └── index.tpl `, - PreRun: func(cmd *commands.Command, args []string) { version.ShowShortVersionBanner() }, + PreRun: nil, Run: CreateApp, } @@ -85,7 +90,14 @@ func init() { beego.Router("/", &controllers.MainController{}) } ` +var goMod = ` +module %s +go %s + +require github.com/astaxie/beego %s +require github.com/smartystreets/goconvey v1.6.4 +` var test = `package test import ( @@ -245,18 +257,39 @@ var reloadJsClient = `function b(a){var c=new WebSocket(a);c.onclose=function(){ ` func init() { + CmdNew.Flag.Var(&module, "module", "Support go modules") + CmdNew.Flag.Var(&beegoVersion, "beego", "set beego version,only take effect by -module=true") commands.AvailableCommands = append(commands.AvailableCommands, CmdNew) } func CreateApp(cmd *commands.Command, args []string) int { output := cmd.Out() - if len(args) != 1 { + if len(args) == 0 { beeLogger.Log.Fatal("Argument [appname] is missing") } - appPath, packPath, err := utils.CheckEnv(args[0]) - if err != nil { - beeLogger.Log.Fatalf("%s", err) + if len(args) >= 2 { + cmd.Flag.Parse(args[1:]) + } else { + module = "false" + } + var appPath string + var packPath string + var err error + if module != `true` { + beeLogger.Log.Info("generate new project support GOPATH") + version.ShowShortVersionBanner() + appPath, packPath, err = utils.CheckEnv(args[0]) + if err != nil { + beeLogger.Log.Fatalf("%s", err) + } + } else { + beeLogger.Log.Info("generate new project support go modules.") + appPath = path.Join(utils.GetBeeWorkPath(), args[0]) + packPath = args[0] + if beegoVersion.String() == `` { + beegoVersion.Set(`v1.12.1`) + } } if utils.IsExist(appPath) { @@ -270,6 +303,10 @@ func CreateApp(cmd *commands.Command, args []string) int { beeLogger.Log.Info("Creating application...") os.MkdirAll(appPath, 0755) + if module == `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") + utils.WriteToFile(path.Join(appPath, "go.mod"), fmt.Sprintf(goMod, packPath, runtime.Version()[2:], beegoVersion.String())) + } fmt.Fprintf(output, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", appPath+string(path.Separator), "\x1b[0m") os.Mkdir(path.Join(appPath, "conf"), 0755) fmt.Fprintf(output, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", path.Join(appPath, "conf")+string(path.Separator), "\x1b[0m") diff --git a/cmd/commands/pack/pack.go b/cmd/commands/pack/pack.go index becddcc..36540ea 100644 --- a/cmd/commands/pack/pack.go +++ b/cmd/commands/pack/pack.go @@ -40,6 +40,7 @@ var CmdPack = &commands.Command{ var ( appPath string + appName string excludeP string excludeS string outputP string @@ -57,6 +58,7 @@ func init() { fs := flag.NewFlagSet("pack", flag.ContinueOnError) fs.StringVar(&appPath, "p", "", "Set the application path. Defaults to the current path.") fs.BoolVar(&build, "b", true, "Tell the command to do a build for the current platform. Defaults to true.") + fs.StringVar(&appName, "a", "", "Set the application name. Defaults to the dir name.") fs.StringVar(&buildArgs, "ba", "", "Specify additional args for Go build.") fs.Var(&buildEnvs, "be", "Specify additional env variables for Go build. e.g. GOARCH=arm.") fs.StringVar(&outputP, "o", "", "Set the compressed file output path. Defaults to the current path.") @@ -445,7 +447,9 @@ func packApp(cmd *commands.Command, args []string) int { beeLogger.Log.Infof("Packaging application on '%s'...", thePath) - appName := path.Base(thePath) + if len(appName) == 0 { + appName = path.Base(thePath) + } goos := runtime.GOOS if v, found := syscall.Getenv("GOOS"); found { @@ -470,7 +474,7 @@ func packApp(cmd *commands.Command, args []string) int { }() if build { - beeLogger.Log.Info("Building application...") + beeLogger.Log.Infof("Building application (%v)...", appName) var envs []string for _, env := range buildEnvs { parts := strings.SplitN(env, "=", 2) @@ -553,7 +557,8 @@ func packApp(cmd *commands.Command, args []string) int { exs = append(exs, p) } } - + exs = append(exs, `go.mod`) + exs = append(exs, `go.sum`) var exr []*regexp.Regexp for _, r := range excludeR { if len(r) > 0 { diff --git a/cmd/commands/run/run.go b/cmd/commands/run/run.go index bcd6251..9eec587 100644 --- a/cmd/commands/run/run.go +++ b/cmd/commands/run/run.go @@ -46,6 +46,8 @@ var ( excludedPaths utils.StrFlags // Pass through to -tags arg of "go build" buildTags string + // Pass through to -ldflags arg of "go build" + buildLDFlags string // Application path currpath string // Application name @@ -72,6 +74,7 @@ func init() { CmdRun.Flag.Var(&excludedPaths, "e", "List of paths to exclude.") CmdRun.Flag.BoolVar(&vendorWatch, "vendor", false, "Enable watch vendor folder.") CmdRun.Flag.StringVar(&buildTags, "tags", "", "Set the build tags. See: https://golang.org/pkg/go/build/") + CmdRun.Flag.StringVar(&buildLDFlags, "ldflags", "", "Set the build ldflags. See: https://golang.org/pkg/go/build/") CmdRun.Flag.StringVar(&runmode, "runmode", "", "Set the Beego run mode.") CmdRun.Flag.StringVar(&runargs, "runargs", "", "Extra args to run application") CmdRun.Flag.Var(&extraPackages, "ex", "List of extra package to watch.") diff --git a/cmd/commands/run/watch.go b/cmd/commands/run/watch.go index 5e6b493..5aae690 100644 --- a/cmd/commands/run/watch.go +++ b/cmd/commands/run/watch.go @@ -39,11 +39,11 @@ var ( watchExts = config.Conf.WatchExts watchExtsStatic = config.Conf.WatchExtsStatic ignoredFilesRegExps = []string{ - `.#(\w+).go`, - `.(\w+).go.swp`, - `(\w+).go~`, - `(\w+).tmp`, - `commentsRouter_controllers.go`, + `.#(\w+).go$`, + `.(\w+).go.swp$`, + `(\w+).go~$`, + `(\w+).tmp$`, + `commentsRouter_controllers.go$`, } ) @@ -158,6 +158,9 @@ func AutoBuild(files []string, isgenerate bool) { if buildTags != "" { args = append(args, "-tags", buildTags) } + if buildLDFlags != "" { + args = append(args, "-ldflags", buildLDFlags) + } args = append(args, files...) bcmd := exec.Command(cmdName, args...) diff --git a/cmd/commands/version/version.go b/cmd/commands/version/version.go index b30128a..4eebd9f 100644 --- a/cmd/commands/version/version.go +++ b/cmd/commands/version/version.go @@ -124,7 +124,7 @@ func GetBeegoVersion() string { } wgopath := utils.GetGOPATHs() if len(wgopath) == 0 { - beeLogger.Log.Error("You need to set GOPATH environment variable") + beeLogger.Log.Error("GOPATH environment is empty,may be you use `go module`") return "" } for _, wg := range wgopath { diff --git a/generate/g_appcode.go b/generate/g_appcode.go index 260472a..014d3a5 100644 --- a/generate/g_appcode.go +++ b/generate/g_appcode.go @@ -15,8 +15,10 @@ package generate import ( + "bufio" "database/sql" "fmt" + "io" "os" "path" "path/filepath" @@ -948,11 +950,40 @@ func getFileName(tbName string) (filename string) { func getPackagePath(curpath string) (packpath string) { gopath := os.Getenv("GOPATH") if gopath == "" { - beeLogger.Log.Fatal("GOPATH environment variable is not set or empty") + info := "GOPATH environment variable is not set or empty" + gomodpath := filepath.Join(curpath, `go.mod`) + re, err := regexp.Compile(`^module\s+(.+)$`) + if err != nil { + beeLogger.Log.Error(info) + beeLogger.Log.Fatalf("try `go.mod` generate regexp error:%s", err) + return "" + } + fd, err := os.Open(gomodpath) + if err != nil { + beeLogger.Log.Error(info) + beeLogger.Log.Fatalf("try `go.mod` Error while reading 'go.mod',%s", gomodpath) + } + reader := bufio.NewReader(fd) + for { + byteLine, _, er := reader.ReadLine() + if er != nil && er != io.EOF { + return "" + } + if er == io.EOF { + break + } + line := string(byteLine) + s := re.FindStringSubmatch(line) + if len(s) >= 2 { + return s[1] + } + } + beeLogger.Log.Error(info) + beeLogger.Log.Fatalf("try `go.mod` Error while parse 'go.mod',%s", gomodpath) + } else { + beeLogger.Log.Debugf("GOPATH: %s", utils.FILE(), utils.LINE(), gopath) } - beeLogger.Log.Debugf("GOPATH: %s", utils.FILE(), utils.LINE(), gopath) - appsrcpath := "" haspath := false wgopath := filepath.SplitList(gopath) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index 512e01c..69fcfe8 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -432,22 +432,27 @@ func analyseControllerPkg(vendorPath, localName, pkgpath string) { pps := strings.Split(pkgpath, "/") importlist[pps[len(pps)-1]] = pkgpath } - gopaths := bu.GetGOPATHs() - if len(gopaths) == 0 { - beeLogger.Log.Fatal("GOPATH environment variable is not set or empty") - } + pkgRealpath := "" - wg, _ := filepath.EvalSymlinks(filepath.Join(vendorPath, pkgpath)) - if utils.FileExists(wg) { - pkgRealpath = wg + if os.Getenv(`GO111MODULE`) == `on` { + pkgRealpath = filepath.Join(bu.GetBeeWorkPath(), "..", pkgpath) } else { - wgopath := gopaths - for _, wg := range wgopath { - wg, _ = filepath.EvalSymlinks(filepath.Join(wg, "src", pkgpath)) - if utils.FileExists(wg) { - pkgRealpath = wg - break + gopaths := bu.GetGOPATHs() + if len(gopaths) == 0 { + beeLogger.Log.Fatal("GOPATH environment variable is not set or empty") + } + wg, _ := filepath.EvalSymlinks(filepath.Join(vendorPath, pkgpath)) + if utils.FileExists(wg) { + pkgRealpath = wg + } else { + wgopath := gopaths + for _, wg := range wgopath { + wg, _ = filepath.EvalSymlinks(filepath.Join(wg, "src", pkgpath)) + if utils.FileExists(wg) { + pkgRealpath = wg + break + } } } } @@ -468,6 +473,7 @@ func analyseControllerPkg(vendorPath, localName, pkgpath string) { if err != nil { beeLogger.Log.Fatalf("Error while parsing dir at '%s': %s", pkgpath, err) } + for _, pkg := range astPkgs { for _, fl := range pkg.Files { for _, d := range fl.Decls { @@ -802,7 +808,7 @@ func setParamType(para *swagger.Parameter, typ string, pkgpath, controllerName s paraFormat = typeFormat[1] if para.In == "body" { para.Schema = &swagger.Schema{ - Type: paraType, + Type: paraType, Format: paraFormat, } } diff --git a/utils/utils.go b/utils/utils.go index 75b6898..ce62421 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -33,6 +33,14 @@ import ( "github.com/beego/bee/logger/colors" ) +func GetBeeWorkPath() string { + beePath, err := filepath.Abs(filepath.Dir(os.Args[0])) + if err != nil { + panic(err) + } + return beePath +} + // Go is a basic promise implementation: it wraps calls a function in a goroutine // and returns a channel which will later return the function's return value. func Go(f func() error) chan error { @@ -305,6 +313,7 @@ func Tmpl(text string, data interface{}) { func CheckEnv(appname string) (apppath, packpath string, err error) { gps := GetGOPATHs() if len(gps) == 0 { + beeLogger.Log.Error("if you want new a go module project,please add param `-module=true` and set env `G111MODULE=on`") beeLogger.Log.Fatal("GOPATH environment variable is not set or empty") } currpath, _ := os.Getwd() From 8cceb7683663638d1da00db2051f986b85512cdb Mon Sep 17 00:00:00 2001 From: qiantao Date: Sun, 28 Jun 2020 14:51:15 +0800 Subject: [PATCH 03/16] fix #477 --- cmd/commands/migrate/migrate.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/commands/migrate/migrate.go b/cmd/commands/migrate/migrate.go index edf6bbb..53cb3da 100644 --- a/cmd/commands/migrate/migrate.go +++ b/cmd/commands/migrate/migrate.go @@ -198,8 +198,8 @@ func checkForSchemaUpdateTable(db *sql.DB, driver string) { beeLogger.Log.Fatalf("Column migration.name type mismatch: TYPE: %s, NULL: %s", typeStr, nullStr) } } else if fieldStr == "created_at" { - if typeStr != "timestamp" || defaultStr != "CURRENT_TIMESTAMP" { - beeLogger.Log.Hint("Expecting TYPE: timestamp, DEFAULT: CURRENT_TIMESTAMP") + if typeStr != "timestamp" || (!strings.EqualFold(defaultStr, "CURRENT_TIMESTAMP") && !strings.EqualFold(defaultStr, "CURRENT_TIMESTAMP()")) { + beeLogger.Log.Hint("Expecting TYPE: timestamp, DEFAULT: CURRENT_TIMESTAMP || CURRENT_TIMESTAMP()") beeLogger.Log.Fatalf("Column migration.timestamp type mismatch: TYPE: %s, DEFAULT: %s", typeStr, defaultStr) } } From 8758f6eaa1a1db9501c7e398d204d5b82c2ac903 Mon Sep 17 00:00:00 2001 From: yitea Date: Sat, 4 Jul 2020 22:58:03 +0800 Subject: [PATCH 04/16] beego pro init --- cmd/bee.go | 1 + cmd/commands/beegopro/beegopro.go | 60 ++++ go.mod | 6 + go.sum | 285 +++++++++++++++++++ internal/app/module/beegopro/config.go | 20 ++ internal/app/module/beegopro/constx.go | 18 ++ internal/app/module/beegopro/container.go | 214 ++++++++++++++ internal/app/module/beegopro/migration.go | 35 +++ internal/app/module/beegopro/pongo2.go | 58 ++++ internal/app/module/beegopro/render.go | 123 ++++++++ internal/app/module/beegopro/schema.go | 151 ++++++++++ internal/app/module/beegopro/schema_model.go | 141 +++++++++ internal/app/module/beegopro/util.go | 185 ++++++++++++ internal/pkg/command/cmd.go | 65 +++++ internal/pkg/git/repository.go | 231 +++++++++++++++ internal/pkg/system/system.go | 22 ++ internal/pkg/utils/file.go | 37 +++ 17 files changed, 1652 insertions(+) create mode 100644 cmd/commands/beegopro/beegopro.go create mode 100644 internal/app/module/beegopro/config.go create mode 100644 internal/app/module/beegopro/constx.go create mode 100644 internal/app/module/beegopro/container.go create mode 100644 internal/app/module/beegopro/migration.go create mode 100644 internal/app/module/beegopro/pongo2.go create mode 100644 internal/app/module/beegopro/render.go create mode 100644 internal/app/module/beegopro/schema.go create mode 100644 internal/app/module/beegopro/schema_model.go create mode 100644 internal/app/module/beegopro/util.go create mode 100644 internal/pkg/command/cmd.go create mode 100644 internal/pkg/git/repository.go create mode 100644 internal/pkg/system/system.go create mode 100644 internal/pkg/utils/file.go diff --git a/cmd/bee.go b/cmd/bee.go index 87ba122..a6c2c80 100644 --- a/cmd/bee.go +++ b/cmd/bee.go @@ -20,6 +20,7 @@ import ( _ "github.com/beego/bee/cmd/commands/api" _ "github.com/beego/bee/cmd/commands/bale" _ "github.com/beego/bee/cmd/commands/beefix" + _ "github.com/beego/bee/cmd/commands/beegopro" _ "github.com/beego/bee/cmd/commands/dlv" _ "github.com/beego/bee/cmd/commands/dockerize" _ "github.com/beego/bee/cmd/commands/generate" diff --git a/cmd/commands/beegopro/beegopro.go b/cmd/commands/beegopro/beegopro.go new file mode 100644 index 0000000..0490e3c --- /dev/null +++ b/cmd/commands/beegopro/beegopro.go @@ -0,0 +1,60 @@ +// Copyright 2013 bee authors +// +// Licensed under the Apache License, Version 2.0 (the "License"): you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. +package beegopro + +import ( + "strings" + + "github.com/beego/bee/cmd/commands" + "github.com/beego/bee/cmd/commands/version" + "github.com/beego/bee/internal/app/module/beegopro" + "github.com/beego/bee/logger" +) + +var CmdBeegoPro = &commands.Command{ + UsageLine: "pro [command]", + Short: "Source code generator", + Long: ``, + PreRun: func(cmd *commands.Command, args []string) { version.ShowShortVersionBanner() }, + Run: BeegoPro, +} + +func init() { + CmdBeegoPro.Flag.Var(&beegopro.SQL, "sql", "sql file path") + commands.AvailableCommands = append(commands.AvailableCommands, CmdBeegoPro) +} + +func BeegoPro(cmd *commands.Command, args []string) int { + if len(args) < 1 { + beeLogger.Log.Fatal("Command is missing") + } + + if len(args) >= 2 { + cmd.Flag.Parse(args[1:]) + } + + gcmd := args[0] + switch gcmd { + case "gen": + beegopro.DefaultBeegoPro.Run() + case "config": + beegopro.DefaultBeegoPro.GenConfig() + case "migration": + beegopro.DefaultBeegoPro.Migration(args) + default: + beeLogger.Log.Fatal("Command is missing") + } + beeLogger.Log.Successf("%s successfully generated!", strings.Title(gcmd)) + return 0 +} diff --git a/go.mod b/go.mod index b9bcf60..aee2524 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,17 @@ module github.com/beego/bee go 1.13 require ( + github.com/BurntSushi/toml v0.3.1 github.com/astaxie/beego v1.12.1 + github.com/davecgh/go-spew v1.1.1 + github.com/flosch/pongo2 v0.0.0-20200529170236-5abacdfa4915 github.com/fsnotify/fsnotify v1.4.9 github.com/gadelkareem/delve v1.4.2-0.20200619175259-dcd01330766f github.com/go-sql-driver/mysql v1.5.0 github.com/gorilla/websocket v1.4.2 github.com/lib/pq v1.7.0 + github.com/pelletier/go-toml v1.2.0 + github.com/smartwalle/pongo2render v1.0.1 + github.com/spf13/viper v1.7.0 gopkg.in/yaml.v2 v2.3.0 ) diff --git a/go.sum b/go.sum index a9fd90e..35bcead 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,48 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OwnLocal/goes v1.0.0/go.mod h1:8rIFjBGTue3lCU0wplczcUgt9Gxgrkkrw7etMIcn8TM= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/astaxie/beego v1.12.1 h1:dfpuoxpzLVgclveAXe4PyNKqkzgm5zF4tgF2B3kkM2I= github.com/astaxie/beego v1.12.1/go.mod h1:kPBWpSANNbSdIqOc8SUL9h+1oyBMZhROeYsXQDbidWQ= github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ= github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60= github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosiner/argv v0.1.0 h1:BVDiEL32lwHukgJKP87btEPenzrrHUjajs/8yzaqcXg= github.com/cosiner/argv v0.1.0/go.mod h1:EusR6TucWKX+zFgtdUsKT2Cvg45K5rtpCcWz4hK06d8= github.com/couchbase/go-couchbase v0.0.0-20181122212707-3e9b6e1258bb/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U= @@ -18,76 +51,328 @@ github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFl github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA= +github.com/flosch/pongo2 v0.0.0-20200529170236-5abacdfa4915 h1:rNVrewdFbSujcoKZifC6cHJfqCTbCIR7XTLHW5TqUWU= +github.com/flosch/pongo2 v0.0.0-20200529170236-5abacdfa4915/go.mod h1:fB4mx6dzqFinCxIf3a7Mf5yLk+18Bia9mPAnuejcvDA= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/gadelkareem/delve v1.4.2-0.20200619175259-dcd01330766f h1:SXR+MNQLeyoKOHwKziU6RU8wKEaGTNhL9rkHRuKND3A= github.com/gadelkareem/delve v1.4.2-0.20200619175259-dcd01330766f/go.mod h1:yRnaIw9CedrRtnrIhNVh1JLOz0cjEUWOEM5FaWEMOV0= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-dap v0.2.0/go.mod h1:5q8aYQFnHOAZEMP+6vmq25HKYAEwE+LF5yh7JKrrhSQ= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= +github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= +github.com/juju/errors v0.0.0-20190930114154-d42613fe1ab9/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= +github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= +github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.7.0 h1:h93mCPfUSkaul3Ka/VG8uZdmW1uMHDGxzu0NWHuJmHY= github.com/lib/pq v1.7.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= +github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mattn/go-colorable v0.0.0-20170327083344-ded68f7a9561 h1:isR/L+BIZ+rqODWYR/f526ygrBMGKZYFhaaFRDGvuZ8= github.com/mattn/go-colorable v0.0.0-20170327083344-ded68f7a9561/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b h1:8uaXtUkxiy+T/zdLWuxa/PG4so0TPZDZfafFNNSaptE= github.com/peterh/liner v0.0.0-20170317030525-88609521dc4b/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg= github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/smartwalle/pongo2render v1.0.1 h1:rsPnDTu/+zIT5HEB5RbMjxKY5hisov26j0isZL/7YS0= +github.com/smartwalle/pongo2render v1.0.1/go.mod h1:MGnTzND7nEMz7g194kjlnw8lx/V5JJlb1hr5kDXEO0I= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.0-20170417170307-b6cb39589372/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v0.0.0-20170417173400-9e4c21054fa1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM= +github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.starlark.net v0.0.0-20190702223751-32f345186213 h1:lkYv5AKwvvduv5XWP6szk/bvvgO6aDeUujhZQXIFTes= go.starlark.net v0.0.0-20190702223751-32f345186213/go.mod h1:c1/X6cHgvdXj6pUlmWKMkuqRnW4K8x2vwt6JAaaircg= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4 h1:QlVATYS7JBoZMVaf+cNjb90WD/beKVHnIxFKT4QaHVI= golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9 h1:L2auWcuQIvxz9xSEqzESnV/QN/gNRXNApHi3fYwl2w0= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200117065230-39095c1d176c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= +gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/internal/app/module/beegopro/config.go b/internal/app/module/beegopro/config.go new file mode 100644 index 0000000..f4854fe --- /dev/null +++ b/internal/app/module/beegopro/config.go @@ -0,0 +1,20 @@ +package beegopro + +import ( + "github.com/beego/bee/internal/pkg/utils" + beeLogger "github.com/beego/bee/logger" + "io/ioutil" +) + +func (c *Container) GenConfig() { + if utils.IsExist(c.BeegoProFile) { + beeLogger.Log.Fatalf("beego pro toml exist") + return + } + + err := ioutil.WriteFile("beegopro.toml", []byte(BeegoToml), 0644) + if err != nil { + beeLogger.Log.Fatalf("write beego pro toml err: %s", err) + return + } +} diff --git a/internal/app/module/beegopro/constx.go b/internal/app/module/beegopro/constx.go new file mode 100644 index 0000000..2e82d13 --- /dev/null +++ b/internal/app/module/beegopro/constx.go @@ -0,0 +1,18 @@ +package beegopro + +const BeegoToml = ` + dsn = "root:123456@tcp(127.0.0.1:3306)/beego" + driver = "mysql" + proType = "default" + enableModule = [] + apiPrefix = "/" + gitRemotePath = "https://github.com/beego-dev/beego-pro.git" + format = true + sourceGen = "text" + gitPull = true + [models.user] + name = ["uid"] + orm = ["auto"] + comment = ["Uid"] + +` diff --git a/internal/app/module/beegopro/container.go b/internal/app/module/beegopro/container.go new file mode 100644 index 0000000..17456ae --- /dev/null +++ b/internal/app/module/beegopro/container.go @@ -0,0 +1,214 @@ +package beegopro + +import ( + "fmt" + "github.com/beego/bee/internal/pkg/git" + "github.com/beego/bee/internal/pkg/system" + beeLogger "github.com/beego/bee/logger" + "github.com/beego/bee/utils" + "github.com/davecgh/go-spew/spew" + "github.com/pelletier/go-toml" + "github.com/spf13/viper" + "io/ioutil" + "sync" + "time" +) + +const MDateFormat = "20060102_150405" + +var DefaultBeegoPro = &Container{ + BeegoProFile: system.CurrentDir + "/beegopro.toml", + TimestampFile: system.CurrentDir + "/beegopro.timestamp", + GoModFile: system.CurrentDir + "/go.mod", + Option: Option{ + Debug: false, + ContextDebug: false, + Dsn: "", + Driver: "mysql", + ProType: "default", + ApiPrefix: "/", + EnableModule: nil, + Models: make(map[string]ModelContent, 0), + GitRemotePath: "https://github.com/beego-dev/beego-pro.git", + Branch: "master", + GitLocalPath: system.BeegoHome + "/beego-pro", + EnableFormat: true, + SourceGen: "text", + EnableGitPull: true, + RefreshGitTime: 24 * 3600, + Path: map[string]string{ + "beego": ".", + }, + EnableGomod: true, + }, + GenerateTime: time.Now().Format(MDateFormat), + GenerateTimeUnix: time.Now().Unix(), + Tmpl: Tmpl{}, + CurPath: system.CurrentDir, + EnableModules: make(map[string]interface{}, 0), // get the user configuration, get the enable module result + FunctionOnce: make(map[string]sync.Once, 0), // get the tmpl configuration, get the function once result +} + +func (c *Container) Run() { + // init git refresh cache time + c.initTimestamp() + c.initBeegoPro() + c.initBeegoTmpl() + c.initRender() + c.flushTimestamp() +} + +func (c *Container) initBeegoPro() { + if !utils.IsExist(c.BeegoProFile) { + beeLogger.Log.Fatalf("beego pro config is not exist, beego json path: %s", c.BeegoProFile) + return + } + viper.SetConfigFile(c.BeegoProFile) + err := viper.ReadInConfig() + if err != nil { + beeLogger.Log.Fatalf("read beego pro config content, err: %s", err.Error()) + return + } + + err = viper.Unmarshal(&c.Option) + if err != nil { + beeLogger.Log.Fatalf("beego pro config unmarshal error, err: %s", err.Error()) + return + } + if c.Option.Debug { + viper.Debug() + } + + if c.Option.EnableGomod { + if !utils.IsExist(c.GoModFile) { + beeLogger.Log.Fatalf("go mod not exist, please create go mod file") + return + } + } + + for _, value := range c.Option.EnableModule { + c.EnableModules[value] = struct{}{} + } + + if len(c.EnableModules) == 0 { + c.EnableModules["*"] = struct{}{} + } + + if c.Option.Debug { + fmt.Println("c.modules", c.EnableModules) + } +} + +func (c *Container) initBeegoTmpl() { + if c.Option.EnableGitPull && (c.GenerateTimeUnix-c.Timestamp.GitCacheLastRefresh > c.Option.RefreshGitTime) { + err := git.CloneORPullRepo(c.Option.GitRemotePath, c.Option.GitLocalPath) + if err != nil { + beeLogger.Log.Fatalf("beego pro git clone or pull repo error, err: %s", err) + return + } + c.Timestamp.GitCacheLastRefresh = c.GenerateTimeUnix + } + + tree, err := toml.LoadFile(c.Option.GitLocalPath + "/" + c.Option.ProType + "/bee.toml") + + if err != nil { + beeLogger.Log.Fatalf("beego tmpl exec error, err: %s", err) + return + } + err = tree.Unmarshal(&c.Tmpl) + if err != nil { + beeLogger.Log.Fatalf("beego tmpl parse error, err: %s", err) + return + } + + if c.Option.Debug { + spew.Dump("tmpl", c.Tmpl) + } + + for _, value := range c.Tmpl.Descriptor { + if value.Once == true { + c.FunctionOnce[value.SrcName] = sync.Once{} + } + } +} + +type modelInfo struct { + Module string + ModelName string + Option Option + Content ModelContent + Descriptor Descriptor + TmplPath string + GenerateTime string +} + +func (c *Container) initRender() { + for _, desc := range c.Tmpl.Descriptor { + _, allFlag := c.EnableModules["*"] + _, moduleFlag := c.EnableModules[desc.Module] + if !allFlag && !moduleFlag { + continue + } + + // model table name, model table schema + for modelName, content := range c.Option.Models { + m := modelInfo{ + Module: desc.Module, + ModelName: modelName, + Content: content, + Option: c.Option, + Descriptor: desc, + TmplPath: c.Tmpl.RenderPath, + GenerateTime: c.GenerateTime, + } + + // some render exec once + syncOnce, flag := c.FunctionOnce[desc.SrcName] + if flag { + syncOnce.Do(func() { + c.renderModel(m) + }) + continue + } + c.renderModel(m) + } + } +} + +func (c *Container) renderModel(m modelInfo) { + render := NewRender(m) + render.Exec(m.Descriptor.SrcName) + if render.Descriptor.IsExistScript() { + err := render.Descriptor.ExecScript(c.CurPath) + if err != nil { + beeLogger.Log.Fatalf("beego exec shell error, err: %s", err) + } + } +} + +func (c *Container) initTimestamp() { + if utils.IsExist(c.TimestampFile) { + tree, err := toml.LoadFile(c.TimestampFile) + if err != nil { + beeLogger.Log.Fatalf("beego timestamp tmpl exec error, err: %s", err) + return + } + err = tree.Unmarshal(&c.Timestamp) + if err != nil { + beeLogger.Log.Fatalf("beego timestamp tmpl parse error, err: %s", err) + return + } + } + c.Timestamp.Generate = c.GenerateTimeUnix +} + +func (c *Container) flushTimestamp() { + tomlByte, err := toml.Marshal(c.Timestamp) + if err != nil { + beeLogger.Log.Fatalf("marshal timestamp tmpl parse error, err: %s", err) + } + err = ioutil.WriteFile(c.TimestampFile, tomlByte, 0644) + if err != nil { + beeLogger.Log.Fatalf("flush timestamp tmpl parse error, err: %s", err) + } +} diff --git a/internal/app/module/beegopro/migration.go b/internal/app/module/beegopro/migration.go new file mode 100644 index 0000000..3626efc --- /dev/null +++ b/internal/app/module/beegopro/migration.go @@ -0,0 +1,35 @@ +package beegopro + +import ( + "database/sql" + beeLogger "github.com/beego/bee/logger" + "github.com/beego/bee/utils" + "io/ioutil" + "path/filepath" +) + +var SQL utils.DocValue + +func (c *Container) Migration(args []string) { + c.initBeegoPro() + db, err := sql.Open(c.Option.Driver, c.Option.Dsn) + if err != nil { + beeLogger.Log.Fatalf("Could not connect to '%s' database using '%s': %s", c.Option.Driver, c.Option.Dsn, err) + return + } + + defer db.Close() + + absFile, _ := filepath.Abs(SQL.String()) + content, err := ioutil.ReadFile(SQL.String()) + if err != nil { + beeLogger.Log.Errorf("read file err %s, abs file %s", err, absFile) + } + + result, err := db.Exec(string(content)) + if err != nil { + beeLogger.Log.Errorf("db exec err %s", err) + } + beeLogger.Log.Infof("db exec info %v", result) + +} diff --git a/internal/app/module/beegopro/pongo2.go b/internal/app/module/beegopro/pongo2.go new file mode 100644 index 0000000..3304230 --- /dev/null +++ b/internal/app/module/beegopro/pongo2.go @@ -0,0 +1,58 @@ +package beegopro + +import ( + "github.com/beego/bee/utils" + "github.com/flosch/pongo2" + "strings" + "unicode/utf8" +) + +func init() { + _ = pongo2.RegisterFilter("lowerFirst", pongo2LowerFirst) + _ = pongo2.RegisterFilter("upperFirst", pongo2UpperFirst) + _ = pongo2.RegisterFilter("snakeString", pongo2SnakeString) + _ = pongo2.RegisterFilter("camelString", pongo2CamelString) +} + +func pongo2LowerFirst(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) { + if in.Len() <= 0 { + return pongo2.AsValue(""), nil + } + t := in.String() + r, size := utf8.DecodeRuneInString(t) + return pongo2.AsValue(strings.ToLower(string(r)) + t[size:]), nil +} + +func pongo2UpperFirst(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) { + if in.Len() <= 0 { + return pongo2.AsValue(""), nil + } + t := in.String() + return pongo2.AsValue(strings.Replace(t, string(t[0]), strings.ToUpper(string(t[0])), 1)), nil +} + +// snake string, XxYy to xx_yy +func pongo2SnakeString(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) { + if in.Len() <= 0 { + return pongo2.AsValue(""), nil + } + t := in.String() + return pongo2.AsValue(utils.SnakeString(t)), nil +} + +// snake string, XxYy to xx_yy +func pongo2CamelString(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) { + if in.Len() <= 0 { + return pongo2.AsValue(""), nil + } + t := in.String() + return pongo2.AsValue(utils.CamelString(t)), nil +} + +func upperFirst(str string) string { + return strings.Replace(str, string(str[0]), strings.ToUpper(string(str[0])), 1) +} + +func lowerFirst(str string) string { + return strings.Replace(str, string(str[0]), strings.ToLower(string(str[0])), 1) +} diff --git a/internal/app/module/beegopro/render.go b/internal/app/module/beegopro/render.go new file mode 100644 index 0000000..4dfa025 --- /dev/null +++ b/internal/app/module/beegopro/render.go @@ -0,0 +1,123 @@ +package beegopro + +import ( + "github.com/beego/bee/internal/pkg/system" + beeLogger "github.com/beego/bee/logger" + "github.com/davecgh/go-spew/spew" + "github.com/flosch/pongo2" + "github.com/smartwalle/pongo2render" + "path" + "path/filepath" +) + +// render +type RenderFile struct { + *pongo2render.Render + Context pongo2.Context + GenerateTime string + Option Option + ModelName string + PackageName string + FlushFile string + PkgPath string + TmplPath string + Descriptor Descriptor +} + +func NewRender(m modelInfo) *RenderFile { + var ( + pathCtx pongo2.Context + newDescriptor Descriptor + ) + + // parse descriptor, get flush file path, beego path, etc... + newDescriptor, pathCtx = m.Descriptor.Parse(m.ModelName, m.Option.Path) + + obj := &RenderFile{ + Context: make(pongo2.Context, 0), + Option: m.Option, + ModelName: m.ModelName, + GenerateTime: m.GenerateTime, + Descriptor: newDescriptor, + } + + obj.FlushFile = newDescriptor.DstPath + + // new render + obj.Render = pongo2render.NewRender(path.Join(obj.Option.GitLocalPath, obj.Option.ProType, m.TmplPath)) + + filePath := path.Dir(obj.FlushFile) + err := createPath(filePath) + if err != nil { + beeLogger.Log.Fatalf("Could not create the controllers directory: %s", err) + } + // get go package path + obj.PkgPath = getPackagePath() + + relativePath, err := filepath.Rel(system.CurrentDir, obj.FlushFile) + if err != nil { + beeLogger.Log.Fatalf("Could not get the relative path: %s", err) + } + + modelSchemas := m.Content.ToModelSchemas() + camelPrimaryKey := modelSchemas.GetPrimaryKey() + importMaps := make(map[string]struct{}, 0) + if modelSchemas.IsExistTime() { + importMaps["time"] = struct{}{} + } + obj.PackageName = filepath.Base(filepath.Dir(relativePath)) + beeLogger.Log.Infof("Using '%s' as name", obj.ModelName) + + beeLogger.Log.Infof("Using '%s' as package name from %s", obj.ModelName, obj.PackageName) + + // package + obj.SetContext("packageName", obj.PackageName) + obj.SetContext("packageImports", importMaps) + + // todo optimize + // todo Set the beego directory, should recalculate the package + if pathCtx["pathRelBeego"] == "." { + obj.SetContext("packagePath", obj.PkgPath) + } else { + obj.SetContext("packagePath", obj.PkgPath+"/"+pathCtx["pathRelBeego"].(string)) + } + + obj.SetContext("packageMod", obj.PkgPath) + + obj.SetContext("modelSchemas", modelSchemas) + obj.SetContext("modelPrimaryKey", camelPrimaryKey) + + for key, value := range pathCtx { + obj.SetContext(key, value) + } + + obj.SetContext("apiPrefix", obj.Option.ApiPrefix) + obj.SetContext("generateTime", obj.GenerateTime) + + if obj.Option.ContextDebug { + spew.Dump(obj.Context) + } + return obj +} + +func (r *RenderFile) SetContext(key string, value interface{}) { + r.Context[key] = value +} + +func (r *RenderFile) Exec(name string) { + var ( + buf string + err error + ) + buf, err = r.Render.Template(name).Execute(r.Context) + if err != nil { + beeLogger.Log.Fatalf("Could not create the %s render tmpl: %s", name, err) + return + } + err = r.write(r.FlushFile, buf) + if err != nil { + beeLogger.Log.Fatalf("Could not create file: %s", err) + return + } + beeLogger.Log.Infof("create file '%s' from %s", r.FlushFile, r.PackageName) +} diff --git a/internal/app/module/beegopro/schema.go b/internal/app/module/beegopro/schema.go new file mode 100644 index 0000000..ceebfe8 --- /dev/null +++ b/internal/app/module/beegopro/schema.go @@ -0,0 +1,151 @@ +package beegopro + +import ( + "fmt" + "github.com/beego/bee/internal/pkg/command" + "github.com/beego/bee/internal/pkg/system" + beeLogger "github.com/beego/bee/logger" + "github.com/beego/bee/utils" + "github.com/flosch/pongo2" + "github.com/smartwalle/pongo2render" + "path/filepath" + "strings" + "sync" +) + +// store all data +type Container struct { + BeegoProFile string // beego pro toml + TimestampFile string // store ts file + GoModFile string // go mod file + Option Option // user option + Tmpl Tmpl // remote tmpl + CurPath string // user current path + EnableModules map[string]interface{} // beego pro provider a collection of module + FunctionOnce map[string]sync.Once // exec function once + Timestamp Timestamp + GenerateTime string + GenerateTimeUnix int64 +} + +// user option +type Option struct { + Debug bool `json:"debug"` + ContextDebug bool `json:"contextDebug"` + Dsn string `json:"dsn"` + Driver string `json:"driver"` + ProType string `json:"proType"` + ApiPrefix string `json:"apiPrefix"` + EnableModule []string `json:"enableModule"` + Models map[string]ModelContent `json:"models"` + GitRemotePath string `json:"gitRemotePath"` + Branch string `json:"branch"` + GitLocalPath string `json:"gitLocalPath"` + EnableFormat bool `json:"enableFormat"` + SourceGen string `json:"sourceGen"` + EnableGitPull bool `json:"enbaleGitPull"` + Path map[string]string `json:"path"` + EnableGomod bool `json:"enableGomod"` + RefreshGitTime int64 `json:"refreshGitTime"` + Extend map[string]string `json:"extend"` // extend user data +} + +type BeegoPro struct { + FilePath string + CurPath string + Option Option +} + +// tmpl option +type Tmpl struct { + RenderPath string `toml:"renderPath"` + Descriptor []Descriptor +} + +type Descriptor struct { + Module string `toml:"module"` + SrcName string `toml:"srcName"` + DstPath string `toml:"dstPath"` + Once bool `toml:"once"` + Script string `toml:"script"` +} + +func (descriptor Descriptor) Parse(modelName string, paths map[string]string) (newDescriptor Descriptor, ctx pongo2.Context) { + var ( + err error + relativeDstPath string + absFile string + relPath string + ) + + newDescriptor = descriptor + render := pongo2render.NewRender("") + ctx = make(pongo2.Context, 0) + for key, value := range paths { + absFile, err = filepath.Abs(value) + if err != nil { + beeLogger.Log.Fatalf("absolute path error %s from key %s and value %s", err, key, value) + } + relPath, err = filepath.Rel(system.CurrentDir, absFile) + if err != nil { + beeLogger.Log.Fatalf("Could not get the relative path: %s", err) + } + // user input path + ctx["path"+utils.CamelCase(key)] = value + // relativePath + ctx["pathRel"+utils.CamelCase(key)] = relPath + } + ctx["modelName"] = lowerFirst(utils.CamelString(modelName)) + relativeDstPath, err = render.TemplateFromString(descriptor.DstPath).Execute(ctx) + if err != nil { + beeLogger.Log.Fatalf("beego tmpl exec error, err: %s", err) + return + } + + newDescriptor.DstPath, err = filepath.Abs(relativeDstPath) + if err != nil { + beeLogger.Log.Fatalf("absolute path error %s from flush file %s", err, relativeDstPath) + } + + newDescriptor.Script, err = render.TemplateFromString(descriptor.Script).Execute(ctx) + if err != nil { + beeLogger.Log.Fatalf("parse script %s, error %s", descriptor.Script, err) + } + return +} + +func (descriptor Descriptor) IsExistScript() bool { + if descriptor.Script != "" { + return true + } + return false +} + +func (d Descriptor) ExecScript(path string) (err error) { + arr := strings.Split(d.Script, " ") + if len(arr) == 0 { + return + } + fmt.Println("path------>", path) + + stdout, stderr, err := command.ExecCmdDir(path, arr[0], arr[1:]...) + if err != nil { + return concatenateError(err, stderr) + } + + beeLogger.Log.Info(stdout) + + return nil +} + +type Timestamp struct { + GitCacheLastRefresh int64 `toml:"gitCacheLastRefresh"` + Generate int64 `toml:"generate"` +} + +func concatenateError(err error, stderr string) error { + if len(stderr) == 0 { + return err + } + return fmt.Errorf("%v: %s", err, stderr) +} diff --git a/internal/app/module/beegopro/schema_model.go b/internal/app/module/beegopro/schema_model.go new file mode 100644 index 0000000..1cb5858 --- /dev/null +++ b/internal/app/module/beegopro/schema_model.go @@ -0,0 +1,141 @@ +package beegopro + +import ( + beeLogger "github.com/beego/bee/logger" + "github.com/beego/bee/utils" + "strings" +) + +type ModelContent struct { + Names []string + Orms []string + Comments []string + Extends []string +} + +type ModelInfo struct { + Name string `json:"name"` // mysql name + InputType string `json:"inputType"` // user input type + MysqlType string `json:"mysqlType"` // mysql type + GoType string `json:"goType"` // go type + Orm string `json:"orm"` // orm tag + Comment string `json:"comment"` // mysql comment + Extend string `json:"extend"` // user extend info +} + +func (m ModelInfo) GetColumnKey() (columnKey string) { + if m.InputType == "auto" || m.Orm == "pk" { + columnKey = "PRI" + } + return +} + +func (m ModelInfo) IsPrimaryKey() (flag bool) { + if m.Orm == "auto" || m.Orm == "pk" || strings.ToLower(m.Name) == "id" { + flag = true + } + return +} + +func (content ModelContent) ToModelInfoArr() (output []ModelInfo) { + namesLen := len(content.Names) + ormsLen := len(content.Orms) + commentsLen := len(content.Comments) + if namesLen != ormsLen && namesLen != commentsLen { + beeLogger.Log.Fatalf("length error, namesLen is %d, ormsLen is %d, commentsLen is %d", namesLen, ormsLen, commentsLen) + } + extendLen := len(content.Extends) + if extendLen != 0 && extendLen != namesLen { + beeLogger.Log.Fatalf("extend length error, namesLen is %d, extendsLen is %d", namesLen, extendLen) + } + + output = make([]ModelInfo, 0) + for i, name := range content.Names { + comment := content.Comments[i] + if comment == "" { + comment = name + } + inputType, goType, mysqlType, ormTag := getModelType(content.Orms[i]) + + m := ModelInfo{ + Name: name, + InputType: inputType, + GoType: goType, + Orm: ormTag, + Comment: comment, + MysqlType: mysqlType, + Extend: "", + } + // extend value + if extendLen != 0 { + m.Extend = content.Extends[i] + } + output = append(output, m) + } + return +} + +func (content ModelContent) ToModelSchemas() (output ModelSchemas) { + modelInfoArr := content.ToModelInfoArr() + + output = make(ModelSchemas, 0) + for i, value := range modelInfoArr { + if i == 0 && !value.IsPrimaryKey() { + inputType, goType, mysqlType, ormTag := getModelType("auto") + output = append(output, &ModelSchema{ + Name: "id", + InputType: inputType, + ColumnKey: "PRI", + Comment: "ID", + MysqlType: mysqlType, + GoType: goType, + OrmTag: ormTag, + Extend: value.Extend, + }) + } + + modelSchema := &ModelSchema{ + Name: value.Name, + InputType: value.InputType, + ColumnKey: value.GetColumnKey(), + MysqlType: value.MysqlType, + Comment: value.Comment, + GoType: value.GoType, + OrmTag: value.Orm, + } + output = append(output, modelSchema) + } + return +} + +type ModelSchema struct { + Name string // column name + InputType string // user input type + MysqlType string // mysql type + ColumnKey string // PRI + Comment string // comment + GoType string // go type + OrmTag string // orm tag + Extend string +} + +type ModelSchemas []*ModelSchema + +func (m ModelSchemas) IsExistTime() bool { + for _, value := range m { + if value.InputType == "datetime" { + return true + } + } + return false +} + +func (m ModelSchemas) GetPrimaryKey() string { + camelPrimaryKey := "" + for _, value := range m { + if value.ColumnKey == "PRI" { + camelPrimaryKey = utils.CamelString(value.Name) + } + } + return camelPrimaryKey +} diff --git a/internal/app/module/beegopro/util.go b/internal/app/module/beegopro/util.go new file mode 100644 index 0000000..d7dd2a0 --- /dev/null +++ b/internal/app/module/beegopro/util.go @@ -0,0 +1,185 @@ +package beegopro + +import ( + "errors" + "fmt" + "github.com/beego/bee/internal/pkg/utils" + beeLogger "github.com/beego/bee/logger" + "go/format" + "io/ioutil" + "os" + "path" + "path/filepath" + "strings" + "time" +) + +// write to file +func (c *RenderFile) write(filename string, buf string) (err error) { + if utils.IsExist(filename) && !isNeedOverwrite(filename) { + return + } + + filePath := path.Dir(filename) + err = createPath(filePath) + if err != nil { + err = errors.New("write create path " + err.Error()) + return + } + + filePathBak := filePath + "/bak" + err = createPath(filePathBak) + if err != nil { + err = errors.New("write create path bak " + err.Error()) + return + } + + name := path.Base(filename) + + if utils.IsExist(filename) { + bakName := fmt.Sprintf("%s/%s.%s.bak", filePathBak, name, time.Now().Format("2006.01.02.15.04.05")) + beeLogger.Log.Infof("bak file '%s'", bakName) + if err := os.Rename(filename, bakName); err != nil { + err = errors.New("file is bak error, path is " + bakName) + return err + } + } + + file, err := os.Create(filename) + defer file.Close() + if err != nil { + err = errors.New("write create file " + err.Error()) + return + } + + output := []byte(buf) + + if c.Option.EnableFormat && filepath.Ext(filename) == ".go" { + // format code + var bts []byte + bts, err = format.Source([]byte(buf)) + if err != nil { + err = errors.New("format buf error " + err.Error()) + return + } + output = bts + } + + err = ioutil.WriteFile(filename, output, 0644) + if err != nil { + err = errors.New("write write file " + err.Error()) + return + } + return +} + +func isNeedOverwrite(fileName string) (flag bool) { + seg := "//" + ext := filepath.Ext(fileName) + if ext == "sql" { + seg = "--" + } + + f, err := os.Open(fileName) + if err != nil { + return + } + defer f.Close() + overwrite := "" + var contentByte []byte + contentByte, err = ioutil.ReadAll(f) + if err != nil { + return + } + for _, s := range strings.Split(string(contentByte), "\n") { + s = strings.TrimSpace(strings.TrimPrefix(s, seg)) + if strings.HasPrefix(s, "@BeeOverwrite") { + overwrite = strings.TrimSpace(s[len("@BeeOverwrite"):]) + } + } + if strings.ToLower(overwrite) == "yes" { + flag = true + return + } + return +} + +// createPath 调用os.MkdirAll递归创建文件夹 +func createPath(filePath string) error { + if !utils.IsExist(filePath) { + err := os.MkdirAll(filePath, os.ModePerm) + return err + } + return nil +} + +func getPackagePath() (packagePath string) { + f, err := os.Open("go.mod") + if err != nil { + return + } + defer f.Close() + var contentByte []byte + contentByte, err = ioutil.ReadAll(f) + if err != nil { + return + } + for _, s := range strings.Split(string(contentByte), "\n") { + packagePath = strings.TrimSpace(strings.TrimPrefix(s, "module")) + return + } + return +} + +func getModelType(orm string) (inputType, goType, mysqlType, tag string) { + kv := strings.SplitN(orm, ",", 2) + inputType = kv[0] + switch inputType { + case "string": + goType = "string" + tag = "size(255)" + // todo use orm data + mysqlType = "varchar(255) NOT NULL" + case "text": + goType = "string" + tag = "type(longtext)" + mysqlType = "longtext NOT NULL" + case "auto": + goType = "int" + tag = "auto" + mysqlType = "int(11) NOT NULL AUTO_INCREMENT" + case "pk": + goType = "int" + tag = "pk" + mysqlType = "int(11) NOT NULL" + case "datetime": + goType = "time.Time" + tag = "type(datetime)" + mysqlType = "datetime NOT NULL" + case "int", "int8", "int16", "int32", "int64": + fallthrough + case "uint", "uint8", "uint16", "uint32", "uint64": + goType = inputType + tag = "" + mysqlType = "int(11) DEFAULT NULL" + case "bool": + goType = inputType + tag = "" + mysqlType = "int(11) DEFAULT NULL" + case "float32", "float64": + goType = inputType + tag = "" + mysqlType = "float NOT NULL" + case "float": + goType = "float64" + tag = "" + mysqlType = "float NOT NULL" + default: + beeLogger.Log.Fatalf("not support type: %s", inputType) + } + // user set orm tag + if len(kv) == 2 { + tag = orm + } + return +} diff --git a/internal/pkg/command/cmd.go b/internal/pkg/command/cmd.go new file mode 100644 index 0000000..95d408e --- /dev/null +++ b/internal/pkg/command/cmd.go @@ -0,0 +1,65 @@ +package command + +import ( + "bytes" + "fmt" + "os/exec" + "strconv" + "strings" +) + +// ExecCmdDirBytes executes system command in given directory +// and return stdout, stderr in bytes type, along with possible error. +func ExecCmdDirBytes(dir, cmdName string, args ...string) ([]byte, []byte, error) { + bufOut := new(bytes.Buffer) + bufErr := new(bytes.Buffer) + + cmd := exec.Command(cmdName, args...) + cmd.Dir = dir + cmd.Stdout = bufOut + cmd.Stderr = bufErr + + err := cmd.Run() + return bufOut.Bytes(), bufErr.Bytes(), err +} + +// ExecCmdBytes executes system command +// and return stdout, stderr in bytes type, along with possible error. +func ExecCmdBytes(cmdName string, args ...string) ([]byte, []byte, error) { + return ExecCmdDirBytes("", cmdName, args...) +} + +// ExecCmdDir executes system command in given directory +// and return stdout, stderr in string type, along with possible error. +func ExecCmdDir(dir, cmdName string, args ...string) (string, string, error) { + bufOut, bufErr, err := ExecCmdDirBytes(dir, cmdName, args...) + return string(bufOut), string(bufErr), err +} + +// ExecCmd executes system command +// and return stdout, stderr in string type, along with possible error. +func ExecCmd(cmdName string, args ...string) (string, string, error) { + return ExecCmdDir("", cmdName, args...) +} + +// 版本对比 v1比v2大返回1,小于返回-1,等于返回0 +func VerCompare(ver1, ver2 string) int { + ver1 = strings.TrimLeft(ver1, "ver") // 清除v,e,r + ver2 = strings.TrimLeft(ver2, "ver") // 清除v,e,r + p1 := strings.Split(ver1, ".") + p2 := strings.Split(ver2, ".") + + ver1 = "" + for _, v := range p1 { + iv, _ := strconv.Atoi(v) + ver1 = fmt.Sprintf("%s%04d", ver1, iv) + } + + ver2 = "" + for _, v := range p2 { + iv, _ := strconv.Atoi(v) + ver2 = fmt.Sprintf("%s%04d", ver2, iv) + } + + return strings.Compare(ver1, ver2) +} diff --git a/internal/pkg/git/repository.go b/internal/pkg/git/repository.go new file mode 100644 index 0000000..c2d1154 --- /dev/null +++ b/internal/pkg/git/repository.go @@ -0,0 +1,231 @@ +package git + +import ( + "errors" + "fmt" + "github.com/beego/bee/internal/pkg/command" + "github.com/beego/bee/internal/pkg/utils" + beeLogger "github.com/beego/bee/logger" + "path/filepath" + "sort" + "strconv" + "strings" +) + +// 获取某项目代码库的标签列表 +func GetTags(repoPath string, limit int) ([]string, error) { + repo, err := OpenRepository(repoPath) + if err != nil { + return nil, err + } + err = repo.Pull() + if err != nil { + return nil, err + } + list, err := repo.GetTags() + if err != nil { + return nil, err + } + if len(list) > limit { + list = list[0:limit] + } + return list, nil +} + +// clone repo +func CloneRepo(url string, dst string) (err error) { + if utils.IsExist(dst) { + return errors.New("dst is not empty, dst is " + dst) + } + if !utils.Mkdir(dst) { + err = errors.New("make dir error, dst is " + dst) + return + } + + beeLogger.Log.Info("start git clone from " + url + ", to dst at " + dst) + _, stderr, err := command.ExecCmd("git", "clone", url, dst) + + if err != nil { + beeLogger.Log.Error("error git clone from " + url + ", to dst at " + dst) + return concatenateError(err, stderr) + } + return nil +} + +// CloneORPullRepo +func CloneORPullRepo(url string, dst string) error { + if !utils.IsDir(dst) { + return CloneRepo(url, dst) + } else { + //projectName, err := getGitProjectName(url) + //if err != nil { + // return err + //} + + //fmt.Println("dst------>", dst) + //projectDir := dst + "/" + projectName + utils.Mkdir(dst) + + repo, err := OpenRepository(dst) + if err != nil { + return err + } + + return repo.Pull() + } +} + +// +func CloneRepoBranch(branch string, url string, dst string) error { + _, stderr, err := command.ExecCmd("git", "clone", "-b", branch, url, dst) + if err != nil { + return concatenateError(err, stderr) + } + return nil +} + +// SortTag ... +type SortTag struct { + data []string +} + +// Len ... +func (t *SortTag) Len() int { + return len(t.data) +} + +// Swap ... +func (t *SortTag) Swap(i, j int) { + t.data[i], t.data[j] = t.data[j], t.data[i] +} + +// Less ... +func (t *SortTag) Less(i, j int) bool { + return command.VerCompare(t.data[i], t.data[j]) == 1 +} + +// Sort ... +func (t *SortTag) Sort() []string { + sort.Sort(t) + return t.data +} + +// Repository ... +type Repository struct { + Path string +} + +// OpenRepository ... +func OpenRepository(repoPath string) (*Repository, error) { + repoPath, err := filepath.Abs(repoPath) + if err != nil { + return nil, err + } else if !utils.IsDir(repoPath) { + return nil, errors.New("no such file or directory") + } + + return &Repository{Path: repoPath}, nil +} + +// 拉取代码 +func (repo *Repository) Pull() error { + beeLogger.Log.Info("git pull " + repo.Path) + _, stderr, err := command.ExecCmdDir(repo.Path, "git", "pull") + if err != nil { + return concatenateError(err, stderr) + } + return nil +} + +// 获取tag列表 +func (repo *Repository) GetTags() ([]string, error) { + stdout, stderr, err := command.ExecCmdDir(repo.Path, "git", "tag", "-l") + if err != nil { + return nil, concatenateError(err, stderr) + } + tags := strings.Split(stdout, "\n") + tags = tags[:len(tags)-1] + + so := &SortTag{data: tags} + return so.Sort(), nil +} + +// 获取两个版本之间的修改日志 +func (repo *Repository) GetChangeLogs(startVer, endVer string) ([]string, error) { + // git log --pretty=format:"%cd %cn: %s" --date=iso v1.8.0...v1.9.0 + stdout, stderr, err := command.ExecCmdDir(repo.Path, "git", "log", "--pretty=format:%cd %cn: %s", "--date=iso", startVer+"..."+endVer) + if err != nil { + return nil, concatenateError(err, stderr) + } + + logs := strings.Split(stdout, "\n") + return logs, nil +} + +// 获取两个版本之间的差异文件列表 +func (repo *Repository) GetChangeFiles(startVer, endVer string, onlyFile bool) ([]string, error) { + // git diff --name-status -b v1.8.0 v1.9.0 + param := "--name-status" + if onlyFile { + param = "--name-only" + } + stdout, stderr, err := command.ExecCmdDir(repo.Path, "git", "diff", param, "-b", startVer, endVer) + if err != nil { + return nil, concatenateError(err, stderr) + } + lines := strings.Split(stdout, "\n") + return lines[:len(lines)-1], nil +} + +// 获取两个版本间的新增或修改的文件数量 +func (repo *Repository) GetDiffFileCount(startVer, endVer string) (int, error) { + cmd := "git diff --name-status -b " + startVer + " " + endVer + " |grep -v ^D |wc -l" + stdout, stderr, err := command.ExecCmdDir(repo.Path, "/bin/bash", "-c", cmd) + if err != nil { + return 0, concatenateError(err, stderr) + } + count, _ := strconv.Atoi(strings.TrimSpace(stdout)) + return count, nil +} + +// 导出版本到tar包 +func (repo *Repository) Export(startVer, endVer string, filename string) error { + // git archive --format=tar.gz $endVer $(git diff --name-status -b $beginVer $endVer |grep -v ^D |grep -v Upgrade/ |awk '{print $2}') -o $tmpFile + + cmd := "" + if startVer == "" { + cmd = "git archive --format=tar " + endVer + " | gzip > " + filename + } else { + cmd = "git archive --format=tar " + endVer + " $(dgit diff --name-status -b " + startVer + " " + endVer + "|grep -v ^D |awk '{print $2}') | gzip > " + filename + } + + _, stderr, err := command.ExecCmdDir(repo.Path, "/bin/bash", "-c", cmd) + + if err != nil { + return concatenateError(err, stderr) + } + return nil +} + +func concatenateError(err error, stderr string) error { + if len(stderr) == 0 { + return err + } + return fmt.Errorf("%v: %s", err, stderr) +} + +// getGitProjectName 获取项目名称 +func getGitProjectName(url string) (name string, err error) { + if !strings.Contains(url, ".git") { + return "", errors.New("Project address does not contain .git") + } + fileSlice := strings.Split(url, "/") + projectName := fileSlice[len(fileSlice)-1] + if projectName == "" { + return "", errors.New("Project name does not exist") + } + + nameSlice := strings.Split(projectName, ".git") + + return nameSlice[0], nil +} diff --git a/internal/pkg/system/system.go b/internal/pkg/system/system.go new file mode 100644 index 0000000..bf7b9fa --- /dev/null +++ b/internal/pkg/system/system.go @@ -0,0 +1,22 @@ +package system + +import ( + "os" + "os/user" + "path/filepath" +) + +// Bee System Params ... +var ( + Usr, _ = user.Current() + BeegoHome = filepath.Join(Usr.HomeDir, "/.beego") + CurrentDir = getCurrentDirectory() + GoPath = os.Getenv("GOPATH") +) + +func getCurrentDirectory() string { + if dir, err := os.Getwd(); err == nil { + return dir + } + return "" +} diff --git a/internal/pkg/utils/file.go b/internal/pkg/utils/file.go new file mode 100644 index 0000000..2dc51ba --- /dev/null +++ b/internal/pkg/utils/file.go @@ -0,0 +1,37 @@ +package utils + +import ( + beeLogger "github.com/beego/bee/logger" + "os" +) + +// Mkdir ... +func Mkdir(dir string) bool { + if dir == "" { + beeLogger.Log.Fatalf("The directory is empty") + return false + } + err := os.MkdirAll(dir, 0755) + if err != nil { + beeLogger.Log.Fatalf("Could not create the directory: %s", err) + return false + } + + beeLogger.Log.Infof("Create %s Success!", dir) + return true +} + +// IsDir ... +func IsDir(dir string) bool { + f, e := os.Stat(dir) + if e != nil { + return false + } + return f.IsDir() +} + +// IsExist returns whether a file or directory exists. +func IsExist(path string) bool { + _, err := os.Stat(path) + return err == nil || os.IsExist(err) +} From 9db1e8fb4c1c50fa27b8986c72247d07e468859b Mon Sep 17 00:00:00 2001 From: yitea Date: Sun, 5 Jul 2020 14:54:26 +0800 Subject: [PATCH 05/16] beego pro add mysql source type --- internal/app/module/beegopro/container.go | 74 ++++++------ internal/app/module/beegopro/migration.go | 6 +- internal/app/module/beegopro/parser.go | 13 ++ internal/app/module/beegopro/parser_mysql.go | 88 ++++++++++++++ internal/app/module/beegopro/parser_text.go | 35 ++++++ internal/app/module/beegopro/render.go | 4 +- internal/app/module/beegopro/schema.go | 53 ++++---- internal/app/module/beegopro/schema_model.go | 54 +-------- .../app/module/beegopro/schema_mysql_model.go | 74 ++++++++++++ internal/app/module/beegopro/schema_render.go | 11 ++ .../app/module/beegopro/schema_text_model.go | 50 ++++++++ internal/pkg/git/repository.go | 9 +- internal/pkg/utils/dsn.go | 113 ++++++++++++++++++ 13 files changed, 452 insertions(+), 132 deletions(-) create mode 100644 internal/app/module/beegopro/parser.go create mode 100644 internal/app/module/beegopro/parser_mysql.go create mode 100644 internal/app/module/beegopro/parser_text.go create mode 100644 internal/app/module/beegopro/schema_mysql_model.go create mode 100644 internal/app/module/beegopro/schema_render.go create mode 100644 internal/app/module/beegopro/schema_text_model.go create mode 100644 internal/pkg/utils/dsn.go diff --git a/internal/app/module/beegopro/container.go b/internal/app/module/beegopro/container.go index 17456ae..2d2cea7 100644 --- a/internal/app/module/beegopro/container.go +++ b/internal/app/module/beegopro/container.go @@ -20,7 +20,7 @@ var DefaultBeegoPro = &Container{ BeegoProFile: system.CurrentDir + "/beegopro.toml", TimestampFile: system.CurrentDir + "/beegopro.timestamp", GoModFile: system.CurrentDir + "/go.mod", - Option: Option{ + UserOption: UserOption{ Debug: false, ContextDebug: false, Dsn: "", @@ -28,7 +28,7 @@ var DefaultBeegoPro = &Container{ ProType: "default", ApiPrefix: "/", EnableModule: nil, - Models: make(map[string]ModelContent, 0), + Models: make(map[string]TextModel, 0), GitRemotePath: "https://github.com/beego-dev/beego-pro.git", Branch: "master", GitLocalPath: system.BeegoHome + "/beego-pro", @@ -43,7 +43,7 @@ var DefaultBeegoPro = &Container{ }, GenerateTime: time.Now().Format(MDateFormat), GenerateTimeUnix: time.Now().Unix(), - Tmpl: Tmpl{}, + TmplOption: TmplOption{}, CurPath: system.CurrentDir, EnableModules: make(map[string]interface{}, 0), // get the user configuration, get the enable module result FunctionOnce: make(map[string]sync.Once, 0), // get the tmpl configuration, get the function once result @@ -52,13 +52,14 @@ var DefaultBeegoPro = &Container{ func (c *Container) Run() { // init git refresh cache time c.initTimestamp() - c.initBeegoPro() - c.initBeegoTmpl() + c.initUserOption() + c.initTemplateOption() + c.initParser() c.initRender() c.flushTimestamp() } -func (c *Container) initBeegoPro() { +func (c *Container) initUserOption() { if !utils.IsExist(c.BeegoProFile) { beeLogger.Log.Fatalf("beego pro config is not exist, beego json path: %s", c.BeegoProFile) return @@ -70,23 +71,23 @@ func (c *Container) initBeegoPro() { return } - err = viper.Unmarshal(&c.Option) + err = viper.Unmarshal(&c.UserOption) if err != nil { beeLogger.Log.Fatalf("beego pro config unmarshal error, err: %s", err.Error()) return } - if c.Option.Debug { + if c.UserOption.Debug { viper.Debug() } - if c.Option.EnableGomod { + if c.UserOption.EnableGomod { if !utils.IsExist(c.GoModFile) { beeLogger.Log.Fatalf("go mod not exist, please create go mod file") return } } - for _, value := range c.Option.EnableModule { + for _, value := range c.UserOption.EnableModule { c.EnableModules[value] = struct{}{} } @@ -94,14 +95,15 @@ func (c *Container) initBeegoPro() { c.EnableModules["*"] = struct{}{} } - if c.Option.Debug { + if c.UserOption.Debug { fmt.Println("c.modules", c.EnableModules) } + } -func (c *Container) initBeegoTmpl() { - if c.Option.EnableGitPull && (c.GenerateTimeUnix-c.Timestamp.GitCacheLastRefresh > c.Option.RefreshGitTime) { - err := git.CloneORPullRepo(c.Option.GitRemotePath, c.Option.GitLocalPath) +func (c *Container) initTemplateOption() { + if c.UserOption.EnableGitPull && (c.GenerateTimeUnix-c.Timestamp.GitCacheLastRefresh > c.UserOption.RefreshGitTime) { + err := git.CloneORPullRepo(c.UserOption.GitRemotePath, c.UserOption.GitLocalPath) if err != nil { beeLogger.Log.Fatalf("beego pro git clone or pull repo error, err: %s", err) return @@ -109,59 +111,49 @@ func (c *Container) initBeegoTmpl() { c.Timestamp.GitCacheLastRefresh = c.GenerateTimeUnix } - tree, err := toml.LoadFile(c.Option.GitLocalPath + "/" + c.Option.ProType + "/bee.toml") + tree, err := toml.LoadFile(c.UserOption.GitLocalPath + "/" + c.UserOption.ProType + "/bee.toml") if err != nil { beeLogger.Log.Fatalf("beego tmpl exec error, err: %s", err) return } - err = tree.Unmarshal(&c.Tmpl) + err = tree.Unmarshal(&c.TmplOption) if err != nil { beeLogger.Log.Fatalf("beego tmpl parse error, err: %s", err) return } - if c.Option.Debug { - spew.Dump("tmpl", c.Tmpl) + if c.UserOption.Debug { + spew.Dump("tmpl", c.TmplOption) } - for _, value := range c.Tmpl.Descriptor { + for _, value := range c.TmplOption.Descriptor { if value.Once == true { c.FunctionOnce[value.SrcName] = sync.Once{} } } } -type modelInfo struct { - Module string - ModelName string - Option Option - Content ModelContent - Descriptor Descriptor - TmplPath string - GenerateTime string +func (c *Container) initParser() { + driver, flag := ParserDriver[c.UserOption.SourceGen] + if !flag { + beeLogger.Log.Fatalf("parse driver not exit, source gen %s", c.UserOption.SourceGen) + } + driver.RegisterOption(c.UserOption, c.TmplOption) + c.Parser = driver } func (c *Container) initRender() { - for _, desc := range c.Tmpl.Descriptor { + for _, desc := range c.TmplOption.Descriptor { _, allFlag := c.EnableModules["*"] _, moduleFlag := c.EnableModules[desc.Module] if !allFlag && !moduleFlag { continue } + models := c.Parser.GetRenderInfos(desc) // model table name, model table schema - for modelName, content := range c.Option.Models { - m := modelInfo{ - Module: desc.Module, - ModelName: modelName, - Content: content, - Option: c.Option, - Descriptor: desc, - TmplPath: c.Tmpl.RenderPath, - GenerateTime: c.GenerateTime, - } - + for _, m := range models { // some render exec once syncOnce, flag := c.FunctionOnce[desc.SrcName] if flag { @@ -175,7 +167,9 @@ func (c *Container) initRender() { } } -func (c *Container) renderModel(m modelInfo) { +func (c *Container) renderModel(m RenderInfo) { + // todo optimize + m.GenerateTime = c.GenerateTime render := NewRender(m) render.Exec(m.Descriptor.SrcName) if render.Descriptor.IsExistScript() { diff --git a/internal/app/module/beegopro/migration.go b/internal/app/module/beegopro/migration.go index 3626efc..11caa2c 100644 --- a/internal/app/module/beegopro/migration.go +++ b/internal/app/module/beegopro/migration.go @@ -11,10 +11,10 @@ import ( var SQL utils.DocValue func (c *Container) Migration(args []string) { - c.initBeegoPro() - db, err := sql.Open(c.Option.Driver, c.Option.Dsn) + c.initUserOption() + db, err := sql.Open(c.UserOption.Driver, c.UserOption.Dsn) if err != nil { - beeLogger.Log.Fatalf("Could not connect to '%s' database using '%s': %s", c.Option.Driver, c.Option.Dsn, err) + beeLogger.Log.Fatalf("Could not connect to '%s' database using '%s': %s", c.UserOption.Driver, c.UserOption.Dsn, err) return } diff --git a/internal/app/module/beegopro/parser.go b/internal/app/module/beegopro/parser.go new file mode 100644 index 0000000..5a8afb2 --- /dev/null +++ b/internal/app/module/beegopro/parser.go @@ -0,0 +1,13 @@ +package beegopro + +type Parser interface { + RegisterOption(userOption UserOption, tmplOption TmplOption) + Parse(descriptor Descriptor) + GetRenderInfos(descriptor Descriptor) (output []RenderInfo) + Unregister() +} + +var ParserDriver = map[string]Parser{ + "text": &TextParser{}, + "mysql": &MysqlParser{}, +} diff --git a/internal/app/module/beegopro/parser_mysql.go b/internal/app/module/beegopro/parser_mysql.go new file mode 100644 index 0000000..204c704 --- /dev/null +++ b/internal/app/module/beegopro/parser_mysql.go @@ -0,0 +1,88 @@ +package beegopro + +import ( + "database/sql" + "fmt" + "github.com/beego/bee/internal/pkg/utils" + beeLogger "github.com/beego/bee/logger" +) + +type MysqlParser struct { + userOption UserOption + tmplOption TmplOption + db *sql.DB +} + +func (m *MysqlParser) RegisterOption(userOption UserOption, tmplOption TmplOption) { + m.userOption = userOption + m.tmplOption = tmplOption + +} + +func (*MysqlParser) Parse(descriptor Descriptor) { + +} + +func (m *MysqlParser) GetRenderInfos(descriptor Descriptor) (output []RenderInfo) { + tableSchemas, err := m.getTableSchemas() + if err != nil { + beeLogger.Log.Fatalf("get table schemas err %s", err) + } + models := tableSchemas.ToTableMap() + + output = make([]RenderInfo, 0) + // model table name, model table schema + for modelName, content := range models { + output = append(output, RenderInfo{ + Module: descriptor.Module, + ModelName: modelName, + Content: content, + Option: m.userOption, + Descriptor: descriptor, + TmplPath: m.tmplOption.RenderPath, + }) + } + return +} + +func (t *MysqlParser) Unregister() { + +} + +func (m *MysqlParser) getTableSchemas() (resp TableSchemas, err error) { + dsn, err := utils.ParseDSN(m.userOption.Dsn) + if err != nil { + beeLogger.Log.Fatalf("parse dsn err %s", err) + return + } + + conn, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/information_schema", dsn.User, dsn.Passwd, dsn.Addr)) + if err != nil { + beeLogger.Log.Fatalf("Could not connect to mysql database using '%s': %s", m.userOption.Dsn, err) + return + } + defer conn.Close() + + q := `SELECT TABLE_NAME, COLUMN_NAME, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, +NUMERIC_PRECISION, NUMERIC_SCALE,COLUMN_TYPE,COLUMN_KEY,COLUMN_COMMENT +FROM COLUMNS WHERE TABLE_SCHEMA = ? ORDER BY TABLE_NAME, ORDINAL_POSITION` + rows, err := conn.Query(q, dsn.DBName) + if err != nil { + return nil, err + } + columns := make(TableSchemas, 0) + for rows.Next() { + cs := TableSchema{} + err := rows.Scan(&cs.TableName, &cs.ColumnName, &cs.IsNullable, &cs.DataType, + &cs.CharacterMaximumLength, &cs.NumericPrecision, &cs.NumericScale, + &cs.ColumnType, &cs.ColumnKey, &cs.Comment) + if err != nil { + return nil, err + } + columns = append(columns, cs) + } + if err := rows.Err(); err != nil { + return nil, err + } + return columns, nil +} diff --git a/internal/app/module/beegopro/parser_text.go b/internal/app/module/beegopro/parser_text.go new file mode 100644 index 0000000..dc14601 --- /dev/null +++ b/internal/app/module/beegopro/parser_text.go @@ -0,0 +1,35 @@ +package beegopro + +type TextParser struct { + userOption UserOption + tmplOption TmplOption +} + +func (t *TextParser) RegisterOption(userOption UserOption, tmplOption TmplOption) { + t.userOption = userOption + t.tmplOption = tmplOption +} + +func (*TextParser) Parse(descriptor Descriptor) { + +} + +func (t *TextParser) GetRenderInfos(descriptor Descriptor) (output []RenderInfo) { + output = make([]RenderInfo, 0) + // model table name, model table schema + for modelName, content := range t.userOption.Models { + output = append(output, RenderInfo{ + Module: descriptor.Module, + ModelName: modelName, + Content: content.ToModelInfos(), + Option: t.userOption, + Descriptor: descriptor, + TmplPath: t.tmplOption.RenderPath, + }) + } + return +} + +func (t *TextParser) Unregister() { + +} diff --git a/internal/app/module/beegopro/render.go b/internal/app/module/beegopro/render.go index 4dfa025..ba5d2b7 100644 --- a/internal/app/module/beegopro/render.go +++ b/internal/app/module/beegopro/render.go @@ -15,7 +15,7 @@ type RenderFile struct { *pongo2render.Render Context pongo2.Context GenerateTime string - Option Option + Option UserOption ModelName string PackageName string FlushFile string @@ -24,7 +24,7 @@ type RenderFile struct { Descriptor Descriptor } -func NewRender(m modelInfo) *RenderFile { +func NewRender(m RenderInfo) *RenderFile { var ( pathCtx pongo2.Context newDescriptor Descriptor diff --git a/internal/app/module/beegopro/schema.go b/internal/app/module/beegopro/schema.go index ceebfe8..f29d981 100644 --- a/internal/app/module/beegopro/schema.go +++ b/internal/app/module/beegopro/schema.go @@ -18,46 +18,41 @@ type Container struct { BeegoProFile string // beego pro toml TimestampFile string // store ts file GoModFile string // go mod file - Option Option // user option - Tmpl Tmpl // remote tmpl + UserOption UserOption // user option + TmplOption TmplOption // tmpl option CurPath string // user current path EnableModules map[string]interface{} // beego pro provider a collection of module FunctionOnce map[string]sync.Once // exec function once Timestamp Timestamp GenerateTime string GenerateTimeUnix int64 + Parser Parser } // user option -type Option struct { - Debug bool `json:"debug"` - ContextDebug bool `json:"contextDebug"` - Dsn string `json:"dsn"` - Driver string `json:"driver"` - ProType string `json:"proType"` - ApiPrefix string `json:"apiPrefix"` - EnableModule []string `json:"enableModule"` - Models map[string]ModelContent `json:"models"` - GitRemotePath string `json:"gitRemotePath"` - Branch string `json:"branch"` - GitLocalPath string `json:"gitLocalPath"` - EnableFormat bool `json:"enableFormat"` - SourceGen string `json:"sourceGen"` - EnableGitPull bool `json:"enbaleGitPull"` - Path map[string]string `json:"path"` - EnableGomod bool `json:"enableGomod"` - RefreshGitTime int64 `json:"refreshGitTime"` - Extend map[string]string `json:"extend"` // extend user data -} - -type BeegoPro struct { - FilePath string - CurPath string - Option Option +type UserOption struct { + Debug bool `json:"debug"` + ContextDebug bool `json:"contextDebug"` + Dsn string `json:"dsn"` + Driver string `json:"driver"` + ProType string `json:"proType"` + ApiPrefix string `json:"apiPrefix"` + EnableModule []string `json:"enableModule"` + Models map[string]TextModel `json:"models"` + GitRemotePath string `json:"gitRemotePath"` + Branch string `json:"branch"` + GitLocalPath string `json:"gitLocalPath"` + EnableFormat bool `json:"enableFormat"` + SourceGen string `json:"sourceGen"` + EnableGitPull bool `json:"enbaleGitPull"` + Path map[string]string `json:"path"` + EnableGomod bool `json:"enableGomod"` + RefreshGitTime int64 `json:"refreshGitTime"` + Extend map[string]string `json:"extend"` // extend user data } // tmpl option -type Tmpl struct { +type TmplOption struct { RenderPath string `toml:"renderPath"` Descriptor []Descriptor } @@ -126,7 +121,6 @@ func (d Descriptor) ExecScript(path string) (err error) { if len(arr) == 0 { return } - fmt.Println("path------>", path) stdout, stderr, err := command.ExecCmdDir(path, arr[0], arr[1:]...) if err != nil { @@ -134,7 +128,6 @@ func (d Descriptor) ExecScript(path string) (err error) { } beeLogger.Log.Info(stdout) - return nil } diff --git a/internal/app/module/beegopro/schema_model.go b/internal/app/module/beegopro/schema_model.go index 1cb5858..25e2c8c 100644 --- a/internal/app/module/beegopro/schema_model.go +++ b/internal/app/module/beegopro/schema_model.go @@ -1,18 +1,11 @@ package beegopro import ( - beeLogger "github.com/beego/bee/logger" "github.com/beego/bee/utils" "strings" ) -type ModelContent struct { - Names []string - Orms []string - Comments []string - Extends []string -} - +// parse get the model info type ModelInfo struct { Name string `json:"name"` // mysql name InputType string `json:"inputType"` // user input type @@ -37,49 +30,12 @@ func (m ModelInfo) IsPrimaryKey() (flag bool) { return } -func (content ModelContent) ToModelInfoArr() (output []ModelInfo) { - namesLen := len(content.Names) - ormsLen := len(content.Orms) - commentsLen := len(content.Comments) - if namesLen != ormsLen && namesLen != commentsLen { - beeLogger.Log.Fatalf("length error, namesLen is %d, ormsLen is %d, commentsLen is %d", namesLen, ormsLen, commentsLen) - } - extendLen := len(content.Extends) - if extendLen != 0 && extendLen != namesLen { - beeLogger.Log.Fatalf("extend length error, namesLen is %d, extendsLen is %d", namesLen, extendLen) - } - - output = make([]ModelInfo, 0) - for i, name := range content.Names { - comment := content.Comments[i] - if comment == "" { - comment = name - } - inputType, goType, mysqlType, ormTag := getModelType(content.Orms[i]) - - m := ModelInfo{ - Name: name, - InputType: inputType, - GoType: goType, - Orm: ormTag, - Comment: comment, - MysqlType: mysqlType, - Extend: "", - } - // extend value - if extendLen != 0 { - m.Extend = content.Extends[i] - } - output = append(output, m) - } - return -} - -func (content ModelContent) ToModelSchemas() (output ModelSchemas) { - modelInfoArr := content.ToModelInfoArr() +type ModelInfos []ModelInfo +// to render model schemas +func (modelInfos ModelInfos) ToModelSchemas() (output ModelSchemas) { output = make(ModelSchemas, 0) - for i, value := range modelInfoArr { + for i, value := range modelInfos { if i == 0 && !value.IsPrimaryKey() { inputType, goType, mysqlType, ormTag := getModelType("auto") output = append(output, &ModelSchema{ diff --git a/internal/app/module/beegopro/schema_mysql_model.go b/internal/app/module/beegopro/schema_mysql_model.go new file mode 100644 index 0000000..177aa0e --- /dev/null +++ b/internal/app/module/beegopro/schema_mysql_model.go @@ -0,0 +1,74 @@ +package beegopro + +import ( + "database/sql" + "errors" + "github.com/beego/bee/logger" +) + +type TableSchema struct { + TableName string + ColumnName string + IsNullable string + DataType string + CharacterMaximumLength sql.NullInt64 + NumericPrecision sql.NullInt64 + NumericScale sql.NullInt64 + ColumnType string + ColumnKey string + Comment string +} + +type TableSchemas []TableSchema + +func (tableSchemas TableSchemas) ToTableMap() (resp map[string]ModelInfos) { + + resp = make(map[string]ModelInfos) + for _, value := range tableSchemas { + if _, ok := resp[value.TableName]; !ok { + resp[value.TableName] = make(ModelInfos, 0) + } + + modelInfos := resp[value.TableName] + inputType, goType, err := value.ToGoType() + if err != nil { + beeLogger.Log.Fatalf("parse go type err %s", err) + return + } + + modelInfo := ModelInfo{ + Name: value.ColumnName, + InputType: inputType, + GoType: goType, + Comment: value.Comment, + } + + if value.ColumnKey == "PRI" { + modelInfo.Orm = "pk" + } + resp[value.TableName] = append(modelInfos, modelInfo) + } + return +} + +// GetGoDataType maps an SQL data type to Golang data type +func (col TableSchema) ToGoType() (inputType string, goType string, err error) { + switch col.DataType { + case "char", "varchar", "enum", "set", "text", "longtext", "mediumtext", "tinytext": + goType = "string" + case "blob", "mediumblob", "longblob", "varbinary", "binary": + goType = "[]byte" + case "date", "time", "datetime", "timestamp": + goType, inputType = "time.Time", "dateTime" + case "tinyint", "smallint", "int", "mediumint": + goType = "int" + case "bit", "bigint": + goType = "int64" + case "float", "decimal", "double": + goType = "float64" + } + if goType == "" { + err = errors.New("No compatible datatype (" + col.DataType + ", CamelName: " + col.ColumnName + ") found") + } + return +} diff --git a/internal/app/module/beegopro/schema_render.go b/internal/app/module/beegopro/schema_render.go new file mode 100644 index 0000000..e7bb531 --- /dev/null +++ b/internal/app/module/beegopro/schema_render.go @@ -0,0 +1,11 @@ +package beegopro + +type RenderInfo struct { + Module string + ModelName string + Option UserOption + Content ModelInfos + Descriptor Descriptor + TmplPath string + GenerateTime string +} diff --git a/internal/app/module/beegopro/schema_text_model.go b/internal/app/module/beegopro/schema_text_model.go new file mode 100644 index 0000000..3483d8f --- /dev/null +++ b/internal/app/module/beegopro/schema_text_model.go @@ -0,0 +1,50 @@ +package beegopro + +import ( + beeLogger "github.com/beego/bee/logger" +) + +type TextModel struct { + Names []string + Orms []string + Comments []string + Extends []string +} + +func (content TextModel) ToModelInfos() (output []ModelInfo) { + namesLen := len(content.Names) + ormsLen := len(content.Orms) + commentsLen := len(content.Comments) + if namesLen != ormsLen && namesLen != commentsLen { + beeLogger.Log.Fatalf("length error, namesLen is %d, ormsLen is %d, commentsLen is %d", namesLen, ormsLen, commentsLen) + } + extendLen := len(content.Extends) + if extendLen != 0 && extendLen != namesLen { + beeLogger.Log.Fatalf("extend length error, namesLen is %d, extendsLen is %d", namesLen, extendLen) + } + + output = make([]ModelInfo, 0) + for i, name := range content.Names { + comment := content.Comments[i] + if comment == "" { + comment = name + } + inputType, goType, mysqlType, ormTag := getModelType(content.Orms[i]) + + m := ModelInfo{ + Name: name, + InputType: inputType, + GoType: goType, + Orm: ormTag, + Comment: comment, + MysqlType: mysqlType, + Extend: "", + } + // extend value + if extendLen != 0 { + m.Extend = content.Extends[i] + } + output = append(output, m) + } + return +} diff --git a/internal/pkg/git/repository.go b/internal/pkg/git/repository.go index c2d1154..d32d597 100644 --- a/internal/pkg/git/repository.go +++ b/internal/pkg/git/repository.go @@ -12,7 +12,7 @@ import ( "strings" ) -// 获取某项目代码库的标签列表 +// git tag func GetTags(repoPath string, limit int) ([]string, error) { repo, err := OpenRepository(repoPath) if err != nil { @@ -57,13 +57,6 @@ func CloneORPullRepo(url string, dst string) error { if !utils.IsDir(dst) { return CloneRepo(url, dst) } else { - //projectName, err := getGitProjectName(url) - //if err != nil { - // return err - //} - - //fmt.Println("dst------>", dst) - //projectDir := dst + "/" + projectName utils.Mkdir(dst) repo, err := OpenRepository(dst) diff --git a/internal/pkg/utils/dsn.go b/internal/pkg/utils/dsn.go new file mode 100644 index 0000000..9948be4 --- /dev/null +++ b/internal/pkg/utils/dsn.go @@ -0,0 +1,113 @@ +package utils + +import ( + "errors" + "net/url" + "strings" +) + +// DSN ... +type DSN struct { + User string // Username + Passwd string // Password (requires User) + Net string // Network type + Addr string // Network address (requires Net) + DBName string // Database name + Params map[string]string // Connection parameters +} + +var ( + errInvalidDSNUnescaped = errors.New("invalid DSN: did you forget to escape a param value?") + errInvalidDSNAddr = errors.New("invalid DSN: network address not terminated (missing closing brace)") + errInvalidDSNNoSlash = errors.New("invalid DSN: missing the slash separating the database name") +) + +// ParseDSN parses the DSN string to a Config +func ParseDSN(dsn string) (cfg *DSN, err error) { + // New config with some default values + cfg = new(DSN) + + // [user[:password]@][net[(addr)]]/dbname[?param1=value1¶mN=valueN] + // Find the last '/' (since the password or the net addr might contain a '/') + foundSlash := false + for i := len(dsn) - 1; i >= 0; i-- { + if dsn[i] == '/' { + foundSlash = true + var j, k int + + // left part is empty if i <= 0 + if i > 0 { + // [username[:password]@][protocol[(address)]] + // Find the last '@' in dsn[:i] + for j = i; j >= 0; j-- { + if dsn[j] == '@' { + // username[:password] + // Find the first ':' in dsn[:j] + for k = 0; k < j; k++ { + if dsn[k] == ':' { + cfg.Passwd = dsn[k+1 : j] + break + } + } + cfg.User = dsn[:k] + + break + } + } + + // [protocol[(address)]] + // Find the first '(' in dsn[j+1:i] + for k = j + 1; k < i; k++ { + if dsn[k] == '(' { + // dsn[i-1] must be == ')' if an address is specified + if dsn[i-1] != ')' { + if strings.ContainsRune(dsn[k+1:i], ')') { + return nil, errInvalidDSNUnescaped + } + return nil, errInvalidDSNAddr + } + cfg.Addr = dsn[k+1 : i-1] + break + } + } + cfg.Net = dsn[j+1 : k] + } + + // dbname[?param1=value1&...¶mN=valueN] + // Find the first '?' in dsn[i+1:] + for j = i + 1; j < len(dsn); j++ { + if dsn[j] == '?' { + if err = parseDSNParams(cfg, dsn[j+1:]); err != nil { + return + } + break + } + } + cfg.DBName = dsn[i+1 : j] + + break + } + } + if !foundSlash && len(dsn) > 0 { + return nil, errInvalidDSNNoSlash + } + return +} + +func parseDSNParams(cfg *DSN, params string) (err error) { + for _, v := range strings.Split(params, "&") { + param := strings.SplitN(v, "=", 2) + if len(param) != 2 { + continue + } + // lazy init + if cfg.Params == nil { + cfg.Params = make(map[string]string) + } + value := param[1] + if cfg.Params[param[0]], err = url.QueryUnescape(value); err != nil { + return + } + } + return +} From 4110083cae88275926fe9917f6e5ba8d4c4319a1 Mon Sep 17 00:00:00 2001 From: qiantao Date: Sat, 11 Jul 2020 12:29:24 +0800 Subject: [PATCH 06/16] generate go.mod skip Minor version. --- cmd/commands/api/apiapp.go | 3 +-- cmd/commands/hprose/hprose.go | 6 ++---- cmd/commands/new/new.go | 3 +-- utils/utils.go | 5 +++++ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/commands/api/apiapp.go b/cmd/commands/api/apiapp.go index 1265329..ba0b45f 100644 --- a/cmd/commands/api/apiapp.go +++ b/cmd/commands/api/apiapp.go @@ -19,7 +19,6 @@ import ( "github.com/beego/bee/logger/colors" "os" path "path/filepath" - "runtime" "strings" "github.com/beego/bee/cmd/commands" @@ -608,7 +607,7 @@ func createAPI(cmd *commands.Command, args []string) int { os.MkdirAll(appPath, 0755) if module == `true` { //generate first for calc model name 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, runtime.Version()[2:], beegoVersion.String())) + utils.WriteToFile(path.Join(appPath, "go.mod"), fmt.Sprintf(goMod, packPath, utils.GetGoVersionSkipMinor(), beegoVersion.String())) } fmt.Fprintf(output, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", appPath, "\x1b[0m") os.Mkdir(path.Join(appPath, "conf"), 0755) diff --git a/cmd/commands/hprose/hprose.go b/cmd/commands/hprose/hprose.go index f926c53..50ba5c1 100644 --- a/cmd/commands/hprose/hprose.go +++ b/cmd/commands/hprose/hprose.go @@ -1,11 +1,9 @@ package hprose import ( + "fmt" "github.com/beego/bee/logger/colors" "os" - "runtime" - - "fmt" "path" "strings" @@ -113,7 +111,7 @@ func createhprose(cmd *commands.Command, args []string) int { os.MkdirAll(apppath, 0755) if module == `true` { //generate first for calc model name 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, runtime.Version()[2:], beegoVersion.String())) + utils.WriteToFile(path.Join(apppath, "go.mod"), fmt.Sprintf(goMod, packpath, utils.GetGoVersionSkipMinor(), beegoVersion.String())) } fmt.Fprintf(output, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", apppath, "\x1b[0m") os.Mkdir(path.Join(apppath, "conf"), 0755) diff --git a/cmd/commands/new/new.go b/cmd/commands/new/new.go index 98c1aed..9510143 100644 --- a/cmd/commands/new/new.go +++ b/cmd/commands/new/new.go @@ -18,7 +18,6 @@ import ( "fmt" "os" path "path/filepath" - "runtime" "strings" "github.com/beego/bee/cmd/commands" @@ -305,7 +304,7 @@ func CreateApp(cmd *commands.Command, args []string) int { os.MkdirAll(appPath, 0755) if module == `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") - utils.WriteToFile(path.Join(appPath, "go.mod"), fmt.Sprintf(goMod, packPath, runtime.Version()[2:], beegoVersion.String())) + utils.WriteToFile(path.Join(appPath, "go.mod"), fmt.Sprintf(goMod, packPath, utils.GetGoVersionSkipMinor(), beegoVersion.String())) } fmt.Fprintf(output, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", appPath+string(path.Separator), "\x1b[0m") os.Mkdir(path.Join(appPath, "conf"), 0755) diff --git a/utils/utils.go b/utils/utils.go index ce62421..f53d7de 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -447,3 +447,8 @@ func defaultGOPATH() string { } return "" } + +func GetGoVersionSkipMinor() string { + strArray := strings.Split(runtime.Version()[2:], `.`) + return strArray[0] + `.` + strArray[1] +} From 4158ab284eb1aaf605d8bafa18946fef8c9bacec Mon Sep 17 00:00:00 2001 From: qiantao Date: Sat, 11 Jul 2020 13:02:25 +0800 Subject: [PATCH 07/16] use `go env` check project is `go mod` or not. --- generate/swaggergen/g_docs.go | 2 +- utils/utils.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index a3e71dc..73ba71b 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -435,7 +435,7 @@ func analyseControllerPkg(vendorPath, localName, pkgpath string) { pkgRealpath := "" - if os.Getenv(`GO111MODULE`) == `on` { + if bu.IsGOMODULE() { pkgRealpath = filepath.Join(bu.GetBeeWorkPath(), "..", pkgpath) } else { gopaths := bu.GetGOPATHs() diff --git a/utils/utils.go b/utils/utils.go index f53d7de..f4516e8 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -452,3 +452,14 @@ func GetGoVersionSkipMinor() string { strArray := strings.Split(runtime.Version()[2:], `.`) return strArray[0] + `.` + strArray[1] } + +func IsGOMODULE() bool { + if combinedOutput, e := exec.Command(`go`, `env`).CombinedOutput(); e != nil { + beeLogger.Log.Errorf("i cann't find go.") + } else { + regex := regexp.MustCompile(`GOMOD="?(.+go.mod)"?`) + stringSubmatch := regex.FindStringSubmatch(string(combinedOutput)) + return len(stringSubmatch) == 2 + } + return false +} From cf3c3bdc8b39f05537eb581a42c3cc102d3e8fcf Mon Sep 17 00:00:00 2001 From: yitea Date: Sat, 11 Jul 2020 17:13:13 +0800 Subject: [PATCH 08/16] fix judge sql ext bug fix orm tag bug change the timestamp file path --- internal/app/module/beegopro/container.go | 2 +- internal/app/module/beegopro/util.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/app/module/beegopro/container.go b/internal/app/module/beegopro/container.go index 2d2cea7..ac0df98 100644 --- a/internal/app/module/beegopro/container.go +++ b/internal/app/module/beegopro/container.go @@ -18,7 +18,7 @@ const MDateFormat = "20060102_150405" var DefaultBeegoPro = &Container{ BeegoProFile: system.CurrentDir + "/beegopro.toml", - TimestampFile: system.CurrentDir + "/beegopro.timestamp", + TimestampFile: system.CurrentDir + "/.beegopro.timestamp", GoModFile: system.CurrentDir + "/go.mod", UserOption: UserOption{ Debug: false, diff --git a/internal/app/module/beegopro/util.go b/internal/app/module/beegopro/util.go index d7dd2a0..79f02a3 100644 --- a/internal/app/module/beegopro/util.go +++ b/internal/app/module/beegopro/util.go @@ -76,7 +76,7 @@ func (c *RenderFile) write(filename string, buf string) (err error) { func isNeedOverwrite(fileName string) (flag bool) { seg := "//" ext := filepath.Ext(fileName) - if ext == "sql" { + if ext == ".sql" { seg = "--" } @@ -179,7 +179,7 @@ func getModelType(orm string) (inputType, goType, mysqlType, tag string) { } // user set orm tag if len(kv) == 2 { - tag = orm + tag = kv[1] } return } From 2c329fd60682b030f97e9059b288abfd501b4751 Mon Sep 17 00:00:00 2001 From: yitea Date: Sat, 11 Jul 2020 17:44:39 +0800 Subject: [PATCH 09/16] support beego pro migration exec sql --- cmd/commands/beegopro/beegopro.go | 2 + internal/app/module/beegopro/migration.go | 56 ++++++++++++++++++++--- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/cmd/commands/beegopro/beegopro.go b/cmd/commands/beegopro/beegopro.go index 0490e3c..978c8f8 100644 --- a/cmd/commands/beegopro/beegopro.go +++ b/cmd/commands/beegopro/beegopro.go @@ -32,6 +32,8 @@ var CmdBeegoPro = &commands.Command{ func init() { CmdBeegoPro.Flag.Var(&beegopro.SQL, "sql", "sql file path") + CmdBeegoPro.Flag.Var(&beegopro.SQLMode, "sqlmode", "sql mode") + CmdBeegoPro.Flag.Var(&beegopro.SQLModePath, "sqlpath", "sql mode path") commands.AvailableCommands = append(commands.AvailableCommands, CmdBeegoPro) } diff --git a/internal/app/module/beegopro/migration.go b/internal/app/module/beegopro/migration.go index 11caa2c..a17a233 100644 --- a/internal/app/module/beegopro/migration.go +++ b/internal/app/module/beegopro/migration.go @@ -6,9 +6,17 @@ import ( "github.com/beego/bee/utils" "io/ioutil" "path/filepath" + "strings" ) var SQL utils.DocValue +var SQLMode utils.DocValue +var SQLModePath utils.DocValue + +var ( + SQLModeUp = "up" + SQLModeDown = "down" +) func (c *Container) Migration(args []string) { c.initUserOption() @@ -17,19 +25,55 @@ func (c *Container) Migration(args []string) { beeLogger.Log.Fatalf("Could not connect to '%s' database using '%s': %s", c.UserOption.Driver, c.UserOption.Dsn, err) return } - defer db.Close() + switch SQLMode.String() { + case SQLModeUp: + doByMode(db, "up.sql") + case SQLModeDown: + doByMode(db, "down.sql") + default: + doBySqlFile(db) + } +} - absFile, _ := filepath.Abs(SQL.String()) - content, err := ioutil.ReadFile(SQL.String()) +func doBySqlFile(db *sql.DB) { + fileName := SQL.String() + if !utils.IsExist(fileName) { + beeLogger.Log.Fatalf("sql mode path not exist, path %s", SQL.String()) + } + doDb(db, fileName) +} + +func doByMode(db *sql.DB, suffix string) { + pathName := SQLModePath.String() + if !utils.IsExist(pathName) { + beeLogger.Log.Fatalf("sql mode path not exist, path %s", SQLModePath.String()) + } + + rd, err := ioutil.ReadDir(pathName) + if err != nil { + beeLogger.Log.Fatalf("read dir err, path %s, err %s", pathName, err) + } + for _, fi := range rd { + if !fi.IsDir() { + if !strings.HasSuffix(fi.Name(), suffix) { + continue + } + doDb(db, filepath.Join(pathName, fi.Name())) + } + } +} + +func doDb(db *sql.DB, filePath string) { + absFile, _ := filepath.Abs(filePath) + content, err := ioutil.ReadFile(filePath) if err != nil { beeLogger.Log.Errorf("read file err %s, abs file %s", err, absFile) } - result, err := db.Exec(string(content)) + _, err = db.Exec(string(content)) if err != nil { beeLogger.Log.Errorf("db exec err %s", err) } - beeLogger.Log.Infof("db exec info %v", result) - + beeLogger.Log.Infof("db exec info %s", filePath) } From fccdcbbedaa5aadd213ff86c2644d758b37ab605 Mon Sep 17 00:00:00 2001 From: qiantao Date: Sun, 28 Jun 2020 14:51:15 +0800 Subject: [PATCH 10/16] fix #477 --- cmd/commands/migrate/migrate.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/commands/migrate/migrate.go b/cmd/commands/migrate/migrate.go index edf6bbb..53cb3da 100644 --- a/cmd/commands/migrate/migrate.go +++ b/cmd/commands/migrate/migrate.go @@ -198,8 +198,8 @@ func checkForSchemaUpdateTable(db *sql.DB, driver string) { beeLogger.Log.Fatalf("Column migration.name type mismatch: TYPE: %s, NULL: %s", typeStr, nullStr) } } else if fieldStr == "created_at" { - if typeStr != "timestamp" || defaultStr != "CURRENT_TIMESTAMP" { - beeLogger.Log.Hint("Expecting TYPE: timestamp, DEFAULT: CURRENT_TIMESTAMP") + if typeStr != "timestamp" || (!strings.EqualFold(defaultStr, "CURRENT_TIMESTAMP") && !strings.EqualFold(defaultStr, "CURRENT_TIMESTAMP()")) { + beeLogger.Log.Hint("Expecting TYPE: timestamp, DEFAULT: CURRENT_TIMESTAMP || CURRENT_TIMESTAMP()") beeLogger.Log.Fatalf("Column migration.timestamp type mismatch: TYPE: %s, DEFAULT: %s", typeStr, defaultStr) } } From 8893ad2d13a61471dfaba7369930a026ec6672a3 Mon Sep 17 00:00:00 2001 From: qiantao Date: Sat, 11 Jul 2020 12:29:24 +0800 Subject: [PATCH 11/16] generate go.mod skip Minor version. --- cmd/commands/api/apiapp.go | 3 +-- cmd/commands/hprose/hprose.go | 6 ++---- cmd/commands/new/new.go | 3 +-- utils/utils.go | 5 +++++ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/commands/api/apiapp.go b/cmd/commands/api/apiapp.go index 1265329..ba0b45f 100644 --- a/cmd/commands/api/apiapp.go +++ b/cmd/commands/api/apiapp.go @@ -19,7 +19,6 @@ import ( "github.com/beego/bee/logger/colors" "os" path "path/filepath" - "runtime" "strings" "github.com/beego/bee/cmd/commands" @@ -608,7 +607,7 @@ func createAPI(cmd *commands.Command, args []string) int { os.MkdirAll(appPath, 0755) if module == `true` { //generate first for calc model name 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, runtime.Version()[2:], beegoVersion.String())) + utils.WriteToFile(path.Join(appPath, "go.mod"), fmt.Sprintf(goMod, packPath, utils.GetGoVersionSkipMinor(), beegoVersion.String())) } fmt.Fprintf(output, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", appPath, "\x1b[0m") os.Mkdir(path.Join(appPath, "conf"), 0755) diff --git a/cmd/commands/hprose/hprose.go b/cmd/commands/hprose/hprose.go index f926c53..50ba5c1 100644 --- a/cmd/commands/hprose/hprose.go +++ b/cmd/commands/hprose/hprose.go @@ -1,11 +1,9 @@ package hprose import ( + "fmt" "github.com/beego/bee/logger/colors" "os" - "runtime" - - "fmt" "path" "strings" @@ -113,7 +111,7 @@ func createhprose(cmd *commands.Command, args []string) int { os.MkdirAll(apppath, 0755) if module == `true` { //generate first for calc model name 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, runtime.Version()[2:], beegoVersion.String())) + utils.WriteToFile(path.Join(apppath, "go.mod"), fmt.Sprintf(goMod, packpath, utils.GetGoVersionSkipMinor(), beegoVersion.String())) } fmt.Fprintf(output, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", apppath, "\x1b[0m") os.Mkdir(path.Join(apppath, "conf"), 0755) diff --git a/cmd/commands/new/new.go b/cmd/commands/new/new.go index 98c1aed..9510143 100644 --- a/cmd/commands/new/new.go +++ b/cmd/commands/new/new.go @@ -18,7 +18,6 @@ import ( "fmt" "os" path "path/filepath" - "runtime" "strings" "github.com/beego/bee/cmd/commands" @@ -305,7 +304,7 @@ func CreateApp(cmd *commands.Command, args []string) int { os.MkdirAll(appPath, 0755) if module == `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") - utils.WriteToFile(path.Join(appPath, "go.mod"), fmt.Sprintf(goMod, packPath, runtime.Version()[2:], beegoVersion.String())) + utils.WriteToFile(path.Join(appPath, "go.mod"), fmt.Sprintf(goMod, packPath, utils.GetGoVersionSkipMinor(), beegoVersion.String())) } fmt.Fprintf(output, "\t%s%screate%s\t %s%s\n", "\x1b[32m", "\x1b[1m", "\x1b[21m", appPath+string(path.Separator), "\x1b[0m") os.Mkdir(path.Join(appPath, "conf"), 0755) diff --git a/utils/utils.go b/utils/utils.go index ce62421..f53d7de 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -447,3 +447,8 @@ func defaultGOPATH() string { } return "" } + +func GetGoVersionSkipMinor() string { + strArray := strings.Split(runtime.Version()[2:], `.`) + return strArray[0] + `.` + strArray[1] +} From 91e4ac31a4bb2639129694ed55f2f227e4ac9a9e Mon Sep 17 00:00:00 2001 From: qiantao Date: Sat, 11 Jul 2020 13:02:25 +0800 Subject: [PATCH 12/16] use `go env` check project is `go mod` or not. --- generate/swaggergen/g_docs.go | 2 +- utils/utils.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/generate/swaggergen/g_docs.go b/generate/swaggergen/g_docs.go index a3e71dc..73ba71b 100644 --- a/generate/swaggergen/g_docs.go +++ b/generate/swaggergen/g_docs.go @@ -435,7 +435,7 @@ func analyseControllerPkg(vendorPath, localName, pkgpath string) { pkgRealpath := "" - if os.Getenv(`GO111MODULE`) == `on` { + if bu.IsGOMODULE() { pkgRealpath = filepath.Join(bu.GetBeeWorkPath(), "..", pkgpath) } else { gopaths := bu.GetGOPATHs() diff --git a/utils/utils.go b/utils/utils.go index f53d7de..f4516e8 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -452,3 +452,14 @@ func GetGoVersionSkipMinor() string { strArray := strings.Split(runtime.Version()[2:], `.`) return strArray[0] + `.` + strArray[1] } + +func IsGOMODULE() bool { + if combinedOutput, e := exec.Command(`go`, `env`).CombinedOutput(); e != nil { + beeLogger.Log.Errorf("i cann't find go.") + } else { + regex := regexp.MustCompile(`GOMOD="?(.+go.mod)"?`) + stringSubmatch := regex.FindStringSubmatch(string(combinedOutput)) + return len(stringSubmatch) == 2 + } + return false +} From adf3cc850f29d59baef78cc0da018aa1a9d21661 Mon Sep 17 00:00:00 2001 From: yitea Date: Thu, 16 Jul 2020 23:17:37 +0800 Subject: [PATCH 13/16] bee pro remove go dependence --- cmd/commands/beegopro/beegopro.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cmd/commands/beegopro/beegopro.go b/cmd/commands/beegopro/beegopro.go index 978c8f8..e30567e 100644 --- a/cmd/commands/beegopro/beegopro.go +++ b/cmd/commands/beegopro/beegopro.go @@ -14,19 +14,16 @@ package beegopro import ( - "strings" - "github.com/beego/bee/cmd/commands" - "github.com/beego/bee/cmd/commands/version" "github.com/beego/bee/internal/app/module/beegopro" "github.com/beego/bee/logger" + "strings" ) var CmdBeegoPro = &commands.Command{ UsageLine: "pro [command]", Short: "Source code generator", Long: ``, - PreRun: func(cmd *commands.Command, args []string) { version.ShowShortVersionBanner() }, Run: BeegoPro, } From f3240109bfa519eb905847d40a2ead1212fb6c8d Mon Sep 17 00:00:00 2001 From: yitea Date: Sat, 18 Jul 2020 22:09:28 +0800 Subject: [PATCH 14/16] bee new uses go mod by default --- cmd/commands/new/new.go | 25 ++++++++++++++--------- internal/app/module/beegopro/container.go | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/cmd/commands/new/new.go b/cmd/commands/new/new.go index 9510143..75bafdb 100644 --- a/cmd/commands/new/new.go +++ b/cmd/commands/new/new.go @@ -27,7 +27,7 @@ import ( "github.com/beego/bee/utils" ) -var module utils.DocValue +var gopath utils.DocValue var beegoVersion utils.DocValue var CmdNew = &commands.Command{ @@ -89,8 +89,7 @@ func init() { beego.Router("/", &controllers.MainController{}) } ` -var goMod = ` -module %s +var goMod = `module %s go %s @@ -256,8 +255,8 @@ var reloadJsClient = `function b(a){var c=new WebSocket(a);c.onclose=function(){ ` func init() { - CmdNew.Flag.Var(&module, "module", "Support go modules") - CmdNew.Flag.Var(&beegoVersion, "beego", "set beego version,only take effect by -module=true") + CmdNew.Flag.Var(&gopath, "gopath", "Support go path") + CmdNew.Flag.Var(&beegoVersion, "beego", "set beego version,only take effect by module mod") commands.AvailableCommands = append(commands.AvailableCommands, CmdNew) } @@ -268,14 +267,15 @@ func CreateApp(cmd *commands.Command, args []string) int { } if len(args) >= 2 { - cmd.Flag.Parse(args[1:]) - } else { - module = "false" + err := cmd.Flag.Parse(args[1:]) + if err != nil { + beeLogger.Log.Fatal("Parse args err " + err.Error()) + } } var appPath string var packPath string var err error - if module != `true` { + if gopath == `true` { beeLogger.Log.Info("generate new project support GOPATH") version.ShowShortVersionBanner() appPath, packPath, err = utils.CheckEnv(args[0]) @@ -301,8 +301,13 @@ func CreateApp(cmd *commands.Command, args []string) int { 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) - 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") utils.WriteToFile(path.Join(appPath, "go.mod"), fmt.Sprintf(goMod, packPath, utils.GetGoVersionSkipMinor(), beegoVersion.String())) } diff --git a/internal/app/module/beegopro/container.go b/internal/app/module/beegopro/container.go index ac0df98..c81870f 100644 --- a/internal/app/module/beegopro/container.go +++ b/internal/app/module/beegopro/container.go @@ -26,7 +26,7 @@ var DefaultBeegoPro = &Container{ Dsn: "", Driver: "mysql", ProType: "default", - ApiPrefix: "/", + ApiPrefix: "/api", EnableModule: nil, Models: make(map[string]TextModel, 0), GitRemotePath: "https://github.com/beego-dev/beego-pro.git", From 4637afa242d9d6498c992de0624027bb9691bc8a Mon Sep 17 00:00:00 2001 From: yitea Date: Sat, 18 Jul 2020 23:08:49 +0800 Subject: [PATCH 15/16] beego pro move to beego group --- internal/app/module/beegopro/container.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/app/module/beegopro/container.go b/internal/app/module/beegopro/container.go index c81870f..296033b 100644 --- a/internal/app/module/beegopro/container.go +++ b/internal/app/module/beegopro/container.go @@ -29,7 +29,7 @@ var DefaultBeegoPro = &Container{ ApiPrefix: "/api", EnableModule: nil, Models: make(map[string]TextModel, 0), - GitRemotePath: "https://github.com/beego-dev/beego-pro.git", + GitRemotePath: "https://github.com/beego/beego-pro.git", Branch: "master", GitLocalPath: system.BeegoHome + "/beego-pro", EnableFormat: true, From cc2b2d10547cd5544ba708a0d020427cbdce463f Mon Sep 17 00:00:00 2001 From: yitea Date: Sun, 19 Jul 2020 20:47:18 +0800 Subject: [PATCH 16/16] bee support go mod, modify readme. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 92b9e7a..04fd01c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Bee is a command-line tool facilitating development of Beego-based application. ## Requirements -- Go version >= 1.3. +- Go version >= 1.12. ## Installation