Skip to content

Commit e267d94

Browse files
authored
chore: update go-zero to v1.2.5 (zeromicro#1410)
1 parent 89ce5e4 commit e267d94

File tree

8 files changed

+25
-25
lines changed

8 files changed

+25
-25
lines changed

tools/goctl/api/format/format.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/tal-tech/go-zero/core/errorx"
1515
"github.com/tal-tech/go-zero/tools/goctl/api/parser"
1616
"github.com/tal-tech/go-zero/tools/goctl/api/util"
17-
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util/pathx"
17+
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
1818
"github.com/urfave/cli"
1919
)
2020

@@ -124,7 +124,7 @@ func apiFormat(data string, filename ...string) (string, error) {
124124
newLineCount++
125125
} else {
126126
if preLine == rightBrace {
127-
builder.WriteString(ctlutil.NL)
127+
builder.WriteString(pathx.NL)
128128
}
129129
newLineCount = 0
130130
}
@@ -152,7 +152,7 @@ func apiFormat(data string, filename ...string) (string, error) {
152152
}
153153
}
154154
util.WriteIndent(&builder, tapCount)
155-
builder.WriteString(line + ctlutil.NL)
155+
builder.WriteString(line + pathx.NL)
156156
if strings.HasSuffix(noCommentLine, leftParenthesis) || strings.HasSuffix(noCommentLine, leftBrace) {
157157
tapCount++
158158
}
@@ -168,10 +168,10 @@ func formatGoTypeDef(line string, scanner *bufio.Scanner, builder *strings.Build
168168
if strings.HasPrefix(noCommentLine, "type") && (strings.HasSuffix(noCommentLine, leftParenthesis) ||
169169
strings.HasSuffix(noCommentLine, leftBrace)) {
170170
var typeBuilder strings.Builder
171-
typeBuilder.WriteString(mayInsertStructKeyword(line, &tokenCount) + ctlutil.NL)
171+
typeBuilder.WriteString(mayInsertStructKeyword(line, &tokenCount) + pathx.NL)
172172
for scanner.Scan() {
173173
noCommentLine := util.RemoveComment(scanner.Text())
174-
typeBuilder.WriteString(mayInsertStructKeyword(scanner.Text(), &tokenCount) + ctlutil.NL)
174+
typeBuilder.WriteString(mayInsertStructKeyword(scanner.Text(), &tokenCount) + pathx.NL)
175175
if noCommentLine == rightBrace || noCommentLine == rightParenthesis {
176176
tokenCount--
177177
}

tools/goctl/api/gogen/genlogic.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
1111
"github.com/tal-tech/go-zero/tools/goctl/config"
1212
"github.com/tal-tech/go-zero/tools/goctl/util/format"
13-
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util/pathx"
13+
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
1414
"github.com/tal-tech/go-zero/tools/goctl/vars"
1515
)
1616

@@ -113,9 +113,9 @@ func getLogicFolderPath(group spec.Group, route spec.Route) string {
113113
func genLogicImports(route spec.Route, parentPkg string) string {
114114
var imports []string
115115
imports = append(imports, `"context"`+"\n")
116-
imports = append(imports, fmt.Sprintf("\"%s\"", ctlutil.JoinPackages(parentPkg, contextDir)))
116+
imports = append(imports, fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, contextDir)))
117117
if shallImportTypesPackage(route) {
118-
imports = append(imports, fmt.Sprintf("\"%s\"\n", ctlutil.JoinPackages(parentPkg, typesDir)))
118+
imports = append(imports, fmt.Sprintf("\"%s\"\n", pathx.JoinPackages(parentPkg, typesDir)))
119119
}
120120
imports = append(imports, fmt.Sprintf("\"%s/core/logx\"", vars.ProjectOpenSourceURL))
121121
return strings.Join(imports, "\n\t")

tools/goctl/api/gogen/genmain.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
88
"github.com/tal-tech/go-zero/tools/goctl/config"
99
"github.com/tal-tech/go-zero/tools/goctl/util/format"
10-
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util/pathx"
10+
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
1111
"github.com/tal-tech/go-zero/tools/goctl/vars"
1212
)
1313

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

6969
func genMainImports(parentPkg string) string {
7070
var imports []string
71-
imports = append(imports, fmt.Sprintf("\"%s\"", ctlutil.JoinPackages(parentPkg, configDir)))
72-
imports = append(imports, fmt.Sprintf("\"%s\"", ctlutil.JoinPackages(parentPkg, handlerDir)))
73-
imports = append(imports, fmt.Sprintf("\"%s\"\n", ctlutil.JoinPackages(parentPkg, contextDir)))
71+
imports = append(imports, fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, configDir)))
72+
imports = append(imports, fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, handlerDir)))
73+
imports = append(imports, fmt.Sprintf("\"%s\"\n", pathx.JoinPackages(parentPkg, contextDir)))
7474
imports = append(imports, fmt.Sprintf("\"%s/core/conf\"", vars.ProjectOpenSourceURL))
7575
imports = append(imports, fmt.Sprintf("\"%s/rest\"", vars.ProjectOpenSourceURL))
7676
return strings.Join(imports, "\n\t")

tools/goctl/api/gogen/gensvc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
88
"github.com/tal-tech/go-zero/tools/goctl/config"
99
"github.com/tal-tech/go-zero/tools/goctl/util/format"
10-
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util/pathx"
10+
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
1111
"github.com/tal-tech/go-zero/tools/goctl/vars"
1212
)
1313

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

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

tools/goctl/api/gogen/util.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
1414
"github.com/tal-tech/go-zero/tools/goctl/api/util"
1515
"github.com/tal-tech/go-zero/tools/goctl/util/ctx"
16-
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util/pathx"
16+
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
1717
)
1818

1919
type fileGenConfig struct {
@@ -41,7 +41,7 @@ func genFile(c fileGenConfig) error {
4141
if len(c.category) == 0 || len(c.templateFile) == 0 {
4242
text = c.builtinTemplate
4343
} else {
44-
text, err = ctlutil.LoadTemplate(c.category, c.templateFile, c.builtinTemplate)
44+
text, err = pathx.LoadTemplate(c.category, c.templateFile, c.builtinTemplate)
4545
if err != nil {
4646
return err
4747
}
@@ -73,7 +73,7 @@ func getParentPackage(dir string) (string, error) {
7373
// fix https://github.com/zeromicro/go-zero/issues/1058
7474
wd := projectCtx.WorkDir
7575
d := projectCtx.Dir
76-
same, err := ctlutil.SameFile(wd, d)
76+
same, err := pathx.SameFile(wd, d)
7777
if err != nil {
7878
return "", err
7979
}

tools/goctl/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/iancoleman/strcase v0.2.0
1111
github.com/logrusorgru/aurora v2.0.3+incompatible
1212
github.com/stretchr/testify v1.7.0
13-
github.com/tal-tech/go-zero v1.2.5-0.20211230062155-e4ab51857606
13+
github.com/tal-tech/go-zero v1.2.5
1414
github.com/urfave/cli v1.22.5
1515
github.com/zeromicro/antlr v0.0.1
1616
github.com/zeromicro/ddl-parser v0.0.0-20210712021150-63520aca7348

tools/goctl/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
349349
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
350350
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
351351
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
352-
github.com/tal-tech/go-zero v1.2.5-0.20211230062155-e4ab51857606 h1:u6Nm/S8pOqHDdjYs8aFBxDGC1BfjVmJoOus4g2RanZE=
353-
github.com/tal-tech/go-zero v1.2.5-0.20211230062155-e4ab51857606/go.mod h1:OM2UangPHFMJ+5boRUaeQ/z6xpVvqprZda/JUWG1D7Y=
352+
github.com/tal-tech/go-zero v1.2.5 h1:DpqTM/OTCThRtJoQPlp6b4/YnbCVkZ3gDT7+nFGUo3k=
353+
github.com/tal-tech/go-zero v1.2.5/go.mod h1:OM2UangPHFMJ+5boRUaeQ/z6xpVvqprZda/JUWG1D7Y=
354354
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
355355
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
356356
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=

tools/goctl/model/sql/parser/parser_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88
"github.com/stretchr/testify/assert"
99
"github.com/tal-tech/go-zero/tools/goctl/model/sql/model"
1010
"github.com/tal-tech/go-zero/tools/goctl/model/sql/util"
11-
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util/pathx"
11+
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
1212
)
1313

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

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

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

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

3333
func TestParseCreateTable(t *testing.T) {
34-
sqlFile := filepath.Join(ctlutil.MustTempDir(), "tmp.sql")
34+
sqlFile := filepath.Join(pathx.MustTempDir(), "tmp.sql")
3535
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)
3636
assert.Nil(t, err)
3737

0 commit comments

Comments
 (0)