rpc service generation (#26)

* add execute files

* add protoc-osx

* add rpc generation

* add rpc generation

* add: rpc template generation

* update usage

* fixed env prepare for project in go path

* optimize gomod cache

* add README.md

* format error

* reactor templatex.go

* remove waste code
This commit is contained in:
Keson
2020-08-28 19:24:58 +08:00
committed by GitHub
parent 71bbf91a63
commit db16115037
36 changed files with 2021 additions and 79 deletions

View File

@@ -5,8 +5,8 @@ import (
"github.com/tal-tech/go-zero/core/collection"
"github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
"github.com/tal-tech/go-zero/tools/goctl/util"
"github.com/tal-tech/go-zero/tools/goctl/util/stringx"
"github.com/tal-tech/go-zero/tools/goctl/util/templatex"
)
func genDelete(table Table, withCache bool) (string, error) {
@@ -28,7 +28,7 @@ func genDelete(table Table, withCache bool) (string, error) {
}
}
camel := table.Name.ToCamel()
output, err := templatex.With("delete").
output, err := util.With("delete").
Parse(template.Delete).
Execute(map[string]interface{}{
"upperStartCamelObject": camel,

View File

@@ -5,7 +5,7 @@ import (
"github.com/tal-tech/go-zero/tools/goctl/model/sql/parser"
"github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
"github.com/tal-tech/go-zero/tools/goctl/util/templatex"
"github.com/tal-tech/go-zero/tools/goctl/util"
)
func genFields(fields []parser.Field) (string, error) {
@@ -25,7 +25,7 @@ func genField(field parser.Field) (string, error) {
if err != nil {
return "", err
}
output, err := templatex.With("types").
output, err := util.With("types").
Parse(template.Field).
Execute(map[string]interface{}{
"name": field.Name.ToCamel(),

View File

@@ -2,13 +2,13 @@ package gen
import (
"github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
"github.com/tal-tech/go-zero/tools/goctl/util"
"github.com/tal-tech/go-zero/tools/goctl/util/stringx"
"github.com/tal-tech/go-zero/tools/goctl/util/templatex"
)
func genFindOne(table Table, withCache bool) (string, error) {
camel := table.Name.ToCamel()
output, err := templatex.With("findOne").
output, err := util.With("findOne").
Parse(template.FindOne).
Execute(map[string]interface{}{
"withCache": withCache,

View File

@@ -5,12 +5,12 @@ import (
"strings"
"github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
"github.com/tal-tech/go-zero/tools/goctl/util"
"github.com/tal-tech/go-zero/tools/goctl/util/stringx"
"github.com/tal-tech/go-zero/tools/goctl/util/templatex"
)
func genFineOneByField(table Table, withCache bool) (string, error) {
t := templatex.With("findOneByField").Parse(template.FindOneByField)
t := util.With("findOneByField").Parse(template.FindOneByField)
var list []string
camelTableName := table.Name.ToCamel()
for _, field := range table.Fields {

View File

@@ -12,7 +12,6 @@ import (
"github.com/tal-tech/go-zero/tools/goctl/util"
"github.com/tal-tech/go-zero/tools/goctl/util/console"
"github.com/tal-tech/go-zero/tools/goctl/util/stringx"
"github.com/tal-tech/go-zero/tools/goctl/util/templatex"
)
const (
@@ -119,7 +118,7 @@ type (
)
func (g *defaultGenerator) genModel(in parser.Table, withCache bool) (string, error) {
t := templatex.With("model").
t := util.With("model").
Parse(template.Model).
GoFmt(true)

View File

@@ -4,8 +4,8 @@ import (
"strings"
"github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
"github.com/tal-tech/go-zero/tools/goctl/util"
"github.com/tal-tech/go-zero/tools/goctl/util/stringx"
"github.com/tal-tech/go-zero/tools/goctl/util/templatex"
)
func genInsert(table Table, withCache bool) (string, error) {
@@ -23,7 +23,7 @@ func genInsert(table Table, withCache bool) (string, error) {
expressionValues = append(expressionValues, "data."+camel)
}
camel := table.Name.ToCamel()
output, err := templatex.With("insert").
output, err := util.With("insert").
Parse(template.Insert).
Execute(map[string]interface{}{
"withCache": withCache,

View File

@@ -2,11 +2,11 @@ package gen
import (
"github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
"github.com/tal-tech/go-zero/tools/goctl/util/templatex"
"github.com/tal-tech/go-zero/tools/goctl/util"
)
func genNew(table Table, withCache bool) (string, error) {
output, err := templatex.With("new").
output, err := util.With("new").
Parse(template.New).
Execute(map[string]interface{}{
"withCache": withCache,

View File

@@ -2,14 +2,14 @@ package gen
import (
"github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
"github.com/tal-tech/go-zero/tools/goctl/util/templatex"
"github.com/tal-tech/go-zero/tools/goctl/util"
)
func genTag(in string) (string, error) {
if in == "" {
return in, nil
}
output, err := templatex.With("tag").
output, err := util.With("tag").
Parse(template.Tag).
Execute(map[string]interface{}{
"field": in,

View File

@@ -2,7 +2,7 @@ package gen
import (
"github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
"github.com/tal-tech/go-zero/tools/goctl/util/templatex"
"github.com/tal-tech/go-zero/tools/goctl/util"
)
func genTypes(table Table, withCache bool) (string, error) {
@@ -11,7 +11,7 @@ func genTypes(table Table, withCache bool) (string, error) {
if err != nil {
return "", err
}
output, err := templatex.With("types").
output, err := util.With("types").
Parse(template.Types).
Execute(map[string]interface{}{
"withCache": withCache,

View File

@@ -4,8 +4,8 @@ import (
"strings"
"github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
"github.com/tal-tech/go-zero/tools/goctl/util"
"github.com/tal-tech/go-zero/tools/goctl/util/stringx"
"github.com/tal-tech/go-zero/tools/goctl/util/templatex"
)
func genUpdate(table Table, withCache bool) (string, error) {
@@ -22,7 +22,7 @@ func genUpdate(table Table, withCache bool) (string, error) {
}
expressionValues = append(expressionValues, "data."+table.PrimaryKey.Name.ToCamel())
camelTableName := table.Name.ToCamel()
output, err := templatex.With("update").
output, err := util.With("update").
Parse(template.Update).
Execute(map[string]interface{}{
"withCache": withCache,

View File

@@ -4,8 +4,8 @@ import (
"strings"
"github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
"github.com/tal-tech/go-zero/tools/goctl/util"
"github.com/tal-tech/go-zero/tools/goctl/util/stringx"
"github.com/tal-tech/go-zero/tools/goctl/util/templatex"
)
func genVars(table Table, withCache bool) (string, error) {
@@ -14,7 +14,7 @@ func genVars(table Table, withCache bool) (string, error) {
keys = append(keys, v.VarExpression)
}
camel := table.Name.ToCamel()
output, err := templatex.With("var").
output, err := util.With("var").
Parse(template.Vars).
GoFmt(true).
Execute(map[string]interface{}{