Skip to content

Commit

Permalink
chore: update go-zero to v1.2.5 (#1410)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan authored Jan 3, 2022
1 parent 89ce5e4 commit e267d94
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
10 changes: 5 additions & 5 deletions tools/goctl/api/format/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/tal-tech/go-zero/core/errorx"
"github.com/tal-tech/go-zero/tools/goctl/api/parser"
"github.com/tal-tech/go-zero/tools/goctl/api/util"
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util/pathx"
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
"github.com/urfave/cli"
)

Expand Down Expand Up @@ -124,7 +124,7 @@ func apiFormat(data string, filename ...string) (string, error) {
newLineCount++
} else {
if preLine == rightBrace {
builder.WriteString(ctlutil.NL)
builder.WriteString(pathx.NL)
}
newLineCount = 0
}
Expand Down Expand Up @@ -152,7 +152,7 @@ func apiFormat(data string, filename ...string) (string, error) {
}
}
util.WriteIndent(&builder, tapCount)
builder.WriteString(line + ctlutil.NL)
builder.WriteString(line + pathx.NL)
if strings.HasSuffix(noCommentLine, leftParenthesis) || strings.HasSuffix(noCommentLine, leftBrace) {
tapCount++
}
Expand All @@ -168,10 +168,10 @@ func formatGoTypeDef(line string, scanner *bufio.Scanner, builder *strings.Build
if strings.HasPrefix(noCommentLine, "type") && (strings.HasSuffix(noCommentLine, leftParenthesis) ||
strings.HasSuffix(noCommentLine, leftBrace)) {
var typeBuilder strings.Builder
typeBuilder.WriteString(mayInsertStructKeyword(line, &tokenCount) + ctlutil.NL)
typeBuilder.WriteString(mayInsertStructKeyword(line, &tokenCount) + pathx.NL)
for scanner.Scan() {
noCommentLine := util.RemoveComment(scanner.Text())
typeBuilder.WriteString(mayInsertStructKeyword(scanner.Text(), &tokenCount) + ctlutil.NL)
typeBuilder.WriteString(mayInsertStructKeyword(scanner.Text(), &tokenCount) + pathx.NL)
if noCommentLine == rightBrace || noCommentLine == rightParenthesis {
tokenCount--
}
Expand Down
6 changes: 3 additions & 3 deletions tools/goctl/api/gogen/genlogic.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
"github.com/tal-tech/go-zero/tools/goctl/config"
"github.com/tal-tech/go-zero/tools/goctl/util/format"
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util/pathx"
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
"github.com/tal-tech/go-zero/tools/goctl/vars"
)

Expand Down Expand Up @@ -113,9 +113,9 @@ func getLogicFolderPath(group spec.Group, route spec.Route) string {
func genLogicImports(route spec.Route, parentPkg string) string {
var imports []string
imports = append(imports, `"context"`+"\n")
imports = append(imports, fmt.Sprintf("\"%s\"", ctlutil.JoinPackages(parentPkg, contextDir)))
imports = append(imports, fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, contextDir)))
if shallImportTypesPackage(route) {
imports = append(imports, fmt.Sprintf("\"%s\"\n", ctlutil.JoinPackages(parentPkg, typesDir)))
imports = append(imports, fmt.Sprintf("\"%s\"\n", pathx.JoinPackages(parentPkg, typesDir)))
}
imports = append(imports, fmt.Sprintf("\"%s/core/logx\"", vars.ProjectOpenSourceURL))
return strings.Join(imports, "\n\t")
Expand Down
8 changes: 4 additions & 4 deletions tools/goctl/api/gogen/genmain.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
"github.com/tal-tech/go-zero/tools/goctl/config"
"github.com/tal-tech/go-zero/tools/goctl/util/format"
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util/pathx"
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
"github.com/tal-tech/go-zero/tools/goctl/vars"
)

Expand Down Expand Up @@ -68,9 +68,9 @@ func genMain(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {

func genMainImports(parentPkg string) string {
var imports []string
imports = append(imports, fmt.Sprintf("\"%s\"", ctlutil.JoinPackages(parentPkg, configDir)))
imports = append(imports, fmt.Sprintf("\"%s\"", ctlutil.JoinPackages(parentPkg, handlerDir)))
imports = append(imports, fmt.Sprintf("\"%s\"\n", ctlutil.JoinPackages(parentPkg, contextDir)))
imports = append(imports, fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, configDir)))
imports = append(imports, fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, handlerDir)))
imports = append(imports, fmt.Sprintf("\"%s\"\n", pathx.JoinPackages(parentPkg, contextDir)))
imports = append(imports, fmt.Sprintf("\"%s/core/conf\"", vars.ProjectOpenSourceURL))
imports = append(imports, fmt.Sprintf("\"%s/rest\"", vars.ProjectOpenSourceURL))
return strings.Join(imports, "\n\t")
Expand Down
6 changes: 3 additions & 3 deletions tools/goctl/api/gogen/gensvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
"github.com/tal-tech/go-zero/tools/goctl/config"
"github.com/tal-tech/go-zero/tools/goctl/util/format"
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util/pathx"
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
"github.com/tal-tech/go-zero/tools/goctl/vars"
)

Expand Down Expand Up @@ -50,9 +50,9 @@ func genServiceContext(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpe
fmt.Sprintf("middleware.New%s().%s", strings.Title(name), "Handle"))
}

configImport := "\"" + ctlutil.JoinPackages(rootPkg, configDir) + "\""
configImport := "\"" + pathx.JoinPackages(rootPkg, configDir) + "\""
if len(middlewareStr) > 0 {
configImport += "\n\t\"" + ctlutil.JoinPackages(rootPkg, middlewareDir) + "\""
configImport += "\n\t\"" + pathx.JoinPackages(rootPkg, middlewareDir) + "\""
configImport += fmt.Sprintf("\n\t\"%s/rest\"", vars.ProjectOpenSourceURL)
}

Expand Down
6 changes: 3 additions & 3 deletions tools/goctl/api/gogen/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
"github.com/tal-tech/go-zero/tools/goctl/api/util"
"github.com/tal-tech/go-zero/tools/goctl/util/ctx"
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util/pathx"
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
)

type fileGenConfig struct {
Expand Down Expand Up @@ -41,7 +41,7 @@ func genFile(c fileGenConfig) error {
if len(c.category) == 0 || len(c.templateFile) == 0 {
text = c.builtinTemplate
} else {
text, err = ctlutil.LoadTemplate(c.category, c.templateFile, c.builtinTemplate)
text, err = pathx.LoadTemplate(c.category, c.templateFile, c.builtinTemplate)
if err != nil {
return err
}
Expand Down Expand Up @@ -73,7 +73,7 @@ func getParentPackage(dir string) (string, error) {
// fix https://github.com/zeromicro/go-zero/issues/1058
wd := projectCtx.WorkDir
d := projectCtx.Dir
same, err := ctlutil.SameFile(wd, d)
same, err := pathx.SameFile(wd, d)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion tools/goctl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/iancoleman/strcase v0.2.0
github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/stretchr/testify v1.7.0
github.com/tal-tech/go-zero v1.2.5-0.20211230062155-e4ab51857606
github.com/tal-tech/go-zero v1.2.5
github.com/urfave/cli v1.22.5
github.com/zeromicro/antlr v0.0.1
github.com/zeromicro/ddl-parser v0.0.0-20210712021150-63520aca7348
Expand Down
4 changes: 2 additions & 2 deletions tools/goctl/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tal-tech/go-zero v1.2.5-0.20211230062155-e4ab51857606 h1:u6Nm/S8pOqHDdjYs8aFBxDGC1BfjVmJoOus4g2RanZE=
github.com/tal-tech/go-zero v1.2.5-0.20211230062155-e4ab51857606/go.mod h1:OM2UangPHFMJ+5boRUaeQ/z6xpVvqprZda/JUWG1D7Y=
github.com/tal-tech/go-zero v1.2.5 h1:DpqTM/OTCThRtJoQPlp6b4/YnbCVkZ3gDT7+nFGUo3k=
github.com/tal-tech/go-zero v1.2.5/go.mod h1:OM2UangPHFMJ+5boRUaeQ/z6xpVvqprZda/JUWG1D7Y=
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
Expand Down
8 changes: 4 additions & 4 deletions tools/goctl/model/sql/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"github.com/stretchr/testify/assert"
"github.com/tal-tech/go-zero/tools/goctl/model/sql/model"
"github.com/tal-tech/go-zero/tools/goctl/model/sql/util"
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util/pathx"
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
)

func TestParsePlainText(t *testing.T) {
sqlFile := filepath.Join(ctlutil.MustTempDir(), "tmp.sql")
sqlFile := filepath.Join(pathx.MustTempDir(), "tmp.sql")
err := ioutil.WriteFile(sqlFile, []byte("plain text"), 0o777)
assert.Nil(t, err)

Expand All @@ -21,7 +21,7 @@ func TestParsePlainText(t *testing.T) {
}

func TestParseSelect(t *testing.T) {
sqlFile := filepath.Join(ctlutil.MustTempDir(), "tmp.sql")
sqlFile := filepath.Join(pathx.MustTempDir(), "tmp.sql")
err := ioutil.WriteFile(sqlFile, []byte("select * from user"), 0o777)
assert.Nil(t, err)

Expand All @@ -31,7 +31,7 @@ func TestParseSelect(t *testing.T) {
}

func TestParseCreateTable(t *testing.T) {
sqlFile := filepath.Join(ctlutil.MustTempDir(), "tmp.sql")
sqlFile := filepath.Join(pathx.MustTempDir(), "tmp.sql")
err := ioutil.WriteFile(sqlFile, []byte("CREATE TABLE `test_user` (\n `id` bigint NOT NULL AUTO_INCREMENT,\n `mobile` varchar(255) COLLATE utf8mb4_bin NOT NULL comment '手\\t机 号',\n `class` bigint NOT NULL comment '班级',\n `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL comment '姓\n 名',\n `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP comment '创建\\r时间',\n `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`),\n UNIQUE KEY `mobile_unique` (`mobile`),\n UNIQUE KEY `class_name_unique` (`class`,`name`),\n KEY `create_index` (`create_time`),\n KEY `name_index` (`name`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;"), 0o777)
assert.Nil(t, err)

Expand Down

0 comments on commit e267d94

Please sign in to comment.