format code (#386)

This commit is contained in:
Kevin Wan
2021-01-14 13:24:24 +08:00
committed by GitHub
parent 744c18b7cb
commit eca4ed2cc0
16 changed files with 114 additions and 96 deletions

View File

@@ -17,8 +17,6 @@ import (
"github.com/urfave/cli"
)
var errNotMatched = errors.New("sql not matched")
const (
flagSrc = "src"
flagDir = "dir"
@@ -29,6 +27,8 @@ const (
flagStyle = "style"
)
var errNotMatched = errors.New("sql not matched")
func MysqlDDL(ctx *cli.Context) error {
src := ctx.String(flagSrc)
dir := ctx.String(flagDir)
@@ -39,6 +39,7 @@ func MysqlDDL(ctx *cli.Context) error {
if err != nil {
return err
}
return fromDDl(src, dir, cfg, cache, idea)
}
@@ -82,13 +83,13 @@ func fromDDl(src, dir string, cfg *config.Config, cache, idea bool) error {
source = append(source, string(data))
}
generator, err := gen.NewDefaultGenerator(dir, cfg, gen.WithConsoleOption(log))
if err != nil {
return err
}
err = generator.StartFromDDL(strings.Join(source, "\n"), cache)
return err
return generator.StartFromDDL(strings.Join(source, "\n"), cache)
}
func fromDataSource(url, pattern, dir string, cfg *config.Config, cache, idea bool) error {
@@ -144,6 +145,5 @@ func fromDataSource(url, pattern, dir string, cfg *config.Config, cache, idea bo
return err
}
err = generator.StartFromInformationSchema(dsn.DBName, matchTables, cache)
return err
return generator.StartFromInformationSchema(dsn.DBName, matchTables, cache)
}