Browse Source

fix: 更新goctl

SongZihuan 1 year ago
parent
commit
cb42a329c5
100 changed files with 407 additions and 526 deletions
  1. 1 1
      tools/goctlwt/api/apigen/gen.go
  2. 1 1
      tools/goctlwt/api/apigen/template.go
  3. 2 2
      tools/goctlwt/api/dartgen/genapi.go
  4. 0 4
      tools/goctlwt/api/dartgen/gendata.go
  5. 22 27
      tools/goctlwt/api/dartgen/vars.go
  6. 1 1
      tools/goctlwt/api/format/format_test.go
  7. 1 1
      tools/goctlwt/api/gogen/gen.go
  8. 1 5
      tools/goctlwt/api/gogen/gen_test.go
  9. 1 1
      tools/goctlwt/api/gogen/genroutes.go
  10. 1 1
      tools/goctlwt/api/gogen/handler.tpl
  11. 1 1
      tools/goctlwt/api/gogen/template.go
  12. 1 1
      tools/goctlwt/api/new/newservice.go
  13. 1 1
      tools/goctlwt/api/new/template.go
  14. 0 1
      tools/goctlwt/api/parser/g4/ast/apiparser.go
  15. 1 1
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser1.go
  16. 1 1
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser2.go
  17. 1 1
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser3.go
  18. 1 1
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser4.go
  19. 1 1
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser5.go
  20. 1 1
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser6.go
  21. 1 1
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser7.go
  22. 1 1
      tools/goctlwt/api/parser/g4/gen/api/apiparser_parser8.go
  23. 1 1
      tools/goctlwt/api/parser/g4/gen/api/apiparser_visitor.go
  24. 2 3
      tools/goctlwt/api/parser/g4/gen/api/file_splitor_test.go
  25. 8 12
      tools/goctlwt/api/parser/parser.go
  26. 3 3
      tools/goctlwt/bug/issue.go
  27. 1 1
      tools/goctlwt/compare/cmd/cmd.go
  28. 1 1
      tools/goctlwt/compare/compare.go
  29. 91 91
      tools/goctlwt/compare/testdata/testcase.go
  30. 6 6
      tools/goctlwt/compare/testdata/testdata.go
  31. 3 3
      tools/goctlwt/config/readme.md
  32. 1 1
      tools/goctlwt/docker/docker.go
  33. 14 14
      tools/goctlwt/env/check.go
  34. 1 1
      tools/goctlwt/example/rpc/hello/client/greet/greet.go
  35. 1 1
      tools/goctlwt/example/rpc/hello/internal/server/greet/greetserver.go
  36. 1 1
      tools/goctlwt/example/rpc/hi/client/event/event.go
  37. 1 1
      tools/goctlwt/example/rpc/hi/client/greet/greet.go
  38. 1 1
      tools/goctlwt/example/rpc/hi/internal/server/event/eventserver.go
  39. 1 1
      tools/goctlwt/example/rpc/hi/internal/server/greet/greetserver.go
  40. 2 2
      tools/goctlwt/gateway/gateway.tpl
  41. 1 1
      tools/goctlwt/gateway/template.go
  42. 5 5
      tools/goctlwt/go.mod
  43. 8 9
      tools/goctlwt/go.sum
  44. 1 1
      tools/goctlwt/goctlwt.go
  45. 4 4
      tools/goctlwt/internal/errorx/errorx.go
  46. 4 4
      tools/goctlwt/internal/version/version.go
  47. 1 1
      tools/goctlwt/kube/kube.go
  48. 1 1
      tools/goctlwt/migrate/mod.go
  49. 2 5
      tools/goctlwt/model/cmd.go
  50. 2 2
      tools/goctlwt/model/mongo/mongo.go
  51. 2 2
      tools/goctlwt/model/mongo/readme.md
  52. 1 1
      tools/goctlwt/model/mongo/template/error.tpl
  53. 1 1
      tools/goctlwt/model/mongo/template/model.tpl
  54. 3 3
      tools/goctlwt/model/mongo/template/model_custom.tpl
  55. 10 11
      tools/goctlwt/model/sql/README.MD
  56. 3 3
      tools/goctlwt/model/sql/builderx/builder.go
  57. 13 7
      tools/goctlwt/model/sql/command/command.go
  58. 2 2
      tools/goctlwt/model/sql/command/migrationnotes/v1.3.4.go
  59. 1 1
      tools/goctlwt/model/sql/command/migrationnotes/v1.3.4_test.go
  60. 4 4
      tools/goctlwt/model/sql/gen/keys_test.go
  61. 14 11
      tools/goctlwt/model/sql/parser/parser.go
  62. 1 1
      tools/goctlwt/model/sql/template/tpl/err.tpl
  63. 1 1
      tools/goctlwt/model/sql/template/tpl/find-one.tpl
  64. 4 4
      tools/goctlwt/model/sql/template/tpl/import-no-cache.tpl
  65. 5 5
      tools/goctlwt/model/sql/template/tpl/import.tpl
  66. 6 0
      tools/goctlwt/model/sql/template/tpl/model-new.tpl
  67. 3 11
      tools/goctlwt/model/sql/template/tpl/model.tpl
  68. 14 8
      tools/goctlwt/model/sql/test/model/model_test.go
  69. 2 2
      tools/goctlwt/model/sql/test/orm.go
  70. 3 12
      tools/goctlwt/pkg/env/env.go
  71. 1 1
      tools/goctlwt/pkg/golang/path.go
  72. 0 31
      tools/goctlwt/pkg/parser/api/importstack/importstack.go
  73. 9 45
      tools/goctlwt/pkg/parser/api/parser/analyzer.go
  74. 18 46
      tools/goctlwt/pkg/parser/api/parser/api.go
  75. 4 0
      tools/goctlwt/pkg/parser/api/parser/testdata/invalid.api
  76. 8 12
      tools/goctlwt/pkg/parser/api/scanner/scanner.go
  77. 1 1
      tools/goctlwt/plugin/plugin.go
  78. 1 1
      tools/goctlwt/quickstart/idl/apilogic.tpl
  79. 1 1
      tools/goctlwt/quickstart/idl/svc.tpl
  80. 1 1
      tools/goctlwt/quickstart/micro.go
  81. 9 9
      tools/goctlwt/rpc/README.md
  82. 2 2
      tools/goctlwt/rpc/cli/cli.go
  83. 1 1
      tools/goctlwt/rpc/cli/zrpc.go
  84. 1 1
      tools/goctlwt/rpc/generator/call.tpl
  85. 1 1
      tools/goctlwt/rpc/generator/config.tpl
  86. 1 1
      tools/goctlwt/rpc/generator/genconfig.go
  87. 6 10
      tools/goctlwt/rpc/generator/genpb.go
  88. 10 10
      tools/goctlwt/rpc/generator/genpb_test.go
  89. 1 1
      tools/goctlwt/rpc/generator/logic.tpl
  90. 3 3
      tools/goctlwt/rpc/generator/main.tpl
  91. 1 1
      tools/goctlwt/rpc/generator/template.go
  92. 2 2
      tools/goctlwt/test/integration/model/mongo/Dockerfile
  93. 4 4
      tools/goctlwt/test/integration/model/mongo/mongo.sh
  94. 1 1
      tools/goctlwt/test/main.sh
  95. 1 1
      tools/goctlwt/update/config/config.go
  96. 1 1
      tools/goctlwt/update/update.go
  97. 4 4
      tools/goctlwt/upgrade/upgrade.go
  98. 1 1
      tools/goctlwt/util/ctx/context.go
  99. 9 9
      tools/goctlwt/util/ctx/gomod_test.go
  100. 1 1
      tools/goctlwt/util/head.go

+ 1 - 1
tools/goctlwt/api/apigen/gen.go

@@ -20,7 +20,7 @@ var apiTemplate string
 var (
 	// VarStringOutput describes the output.
 	VarStringOutput string
-	// VarStringHome describes the goctl home.
+	// VarStringHome describes the goctlwt home.
 	VarStringHome string
 	// VarStringRemote describes the remote git repository.
 	VarStringRemote string

+ 1 - 1
tools/goctlwt/api/apigen/template.go

@@ -39,7 +39,7 @@ func RevertTemplate(name string) error {
 	return pathx.CreateTemplate(category, name, content)
 }
 
-// Update updates the template files to the templates built in current goctl.
+// Update updates the template files to the templates built in current goctlwt.
 func Update() error {
 	err := Clean()
 	if err != nil {

+ 2 - 2
tools/goctlwt/api/dartgen/genapi.go

@@ -15,8 +15,8 @@ import '../data/{{with .Info}}{{getBaseName .Title}}{{end}}.dart';
 {{range .Routes}}
 /// --{{.Path}}--
 ///
-/// request: {{with .RequestType}}{{.Name}}{{end}}
-/// response: {{with .ResponseType}}{{.Name}}{{end}}
+/// 请求: {{with .RequestType}}{{.Name}}{{end}}
+/// 返回: {{with .ResponseType}}{{.Name}}{{end}}
 Future {{pathToFuncName .Path}}( {{if ne .Method "get"}}{{with .RequestType}}{{.Name}} request,{{end}}{{end}}
     {Function({{with .ResponseType}}{{.Name}}{{end}}) ok,
     Function(String) fail,

+ 0 - 4
tools/goctlwt/api/dartgen/gendata.go

@@ -51,8 +51,6 @@ class {{.Name}} {
 						m['{{getPropertyFromMember .}}']?.cast<{{getCoreType .Type.Name}}>() {{appendDefaultEmptyValue .Type.Name}}
 					{{else if isClassListType .Type.Name}}
 						((m['{{getPropertyFromMember .}}'] {{appendDefaultEmptyValue .Type.Name}}) as List<dynamic>).map((i) => {{getCoreType .Type.Name}}.fromJson(i)).toList()
-					{{else if isMapType .Type.Name}}
-						{{if isNumberType .Type.Name}}num{{else}}{{.Type.Name}}{{end}}.from(m['{{getPropertyFromMember .}}'] ?? {})
 					{{else}}
 						{{.Type.Name}}.fromJson(m['{{getPropertyFromMember .}}']){{end}}
 			,{{end}}
@@ -63,8 +61,6 @@ class {{.Name}} {
 			'{{getPropertyFromMember .}}': 
 				{{if isDirectType .Type.Name}}
 					{{lowCamelCase .Name}}
-				{{else if isMapType .Type.Name}}
-					{{lowCamelCase .Name}}
 				{{else if isClassListType .Type.Name}}
 					{{lowCamelCase .Name}}{{if isNullableType .Type.Name}}?{{end}}.map((i) => i{{if isListItemsNullable .Type.Name}}?{{end}}.toJson())
 				{{else}}

+ 22 - 27
tools/goctlwt/api/dartgen/vars.go

@@ -3,24 +3,23 @@ package dartgen
 import "text/template"
 
 var funcMap = template.FuncMap{
-	"appendNullCoalescing":            appendNullCoalescing,
-	"appendDefaultEmptyValue":         appendDefaultEmptyValue,
-	"extractPositionalParamsFromPath": extractPositionalParamsFromPath,
 	"getBaseName":                     getBaseName,
-	"getCoreType":                     getCoreType,
 	"getPropertyFromMember":           getPropertyFromMember,
-	"hasUrlPathParams":                hasUrlPathParams,
-	"isAtomicListType":                isAtomicListType,
-	"isAtomicType":                    isAtomicType,
 	"isDirectType":                    isDirectType,
+	"isAtomicType":                    isAtomicType,
+	"isNumberType":                    isNumberType,
 	"isClassListType":                 isClassListType,
+	"isAtomicListType":                isAtomicListType,
 	"isListItemsNullable":             isListItemsNullable,
-	"isMapType":                       isMapType,
 	"isNullableType":                  isNullableType,
-	"isNumberType":                    isNumberType,
+	"appendNullCoalescing":            appendNullCoalescing,
+	"appendDefaultEmptyValue":         appendDefaultEmptyValue,
+	"getCoreType":                     getCoreType,
 	"lowCamelCase":                    lowCamelCase,
-	"makeDartRequestUrlPath":          makeDartRequestUrlPath,
 	"normalizeHandlerName":            normalizeHandlerName,
+	"hasUrlPathParams":                hasUrlPathParams,
+	"extractPositionalParamsFromPath": extractPositionalParamsFromPath,
+	"makeDartRequestUrlPath":          makeDartRequestUrlPath,
 }
 
 const (
@@ -29,32 +28,28 @@ import 'dart:convert';
 import '../vars/kv.dart';
 import '../vars/vars.dart';
 
-/// Send GET request.
+/// 发送POST请求.
 ///
-/// ok: the function that will be called on success.
-/// fail:the fuction that will be called on failure.
-/// eventually:the function that will be called regardless of success or failure.
-Future apiGet(String path,
+/// data:为你要post的结构体,我们会帮你转换成json字符串;
+/// ok函数:请求成功的时候调用,fail函数:请求失败的时候会调用,eventually函数:无论成功失败都会调用
+Future apiPost(String path, dynamic data,
     {Map<String, String> header,
     Function(Map<String, dynamic>) ok,
     Function(String) fail,
     Function eventually}) async {
-  await _apiRequest('GET', path, null,
+  await _apiRequest('POST', path, data,
       header: header, ok: ok, fail: fail, eventually: eventually);
 }
 
-/// Send POST request.
+/// 发送GET请求.
 ///
-/// data: the data to post, it will be marshaled to json automatically.
-/// ok: the function that will be called on success.
-/// fail:the fuction that will be called on failure.
-/// eventually:the function that will be called regardless of success or failure.
-Future apiPost(String path, dynamic data,
+/// ok函数:请求成功的时候调用,fail函数:请求失败的时候会调用,eventually函数:无论成功失败都会调用
+Future apiGet(String path,
     {Map<String, String> header,
     Function(Map<String, dynamic>) ok,
     Function(String) fail,
     Function eventually}) async {
-  await _apiRequest('POST', path, data,
+  await _apiRequest('GET', path, null,
       header: header, ok: ok, fail: fail, eventually: eventually);
 }
 
@@ -217,11 +212,11 @@ Future _apiRequest(String method, String path, dynamic data,
 	}`
 
 	tokensFileContent = `class Tokens {
-  /// the token used to access, it must be carried in the header of each request
+  /// 用于访问的token, 每次请求都必须带在Header里面
   final String accessToken;
   final int accessExpire;
 
-  /// the token used to refresh
+  /// 用于刷新token
   final String refreshToken;
   final int refreshExpire;
   final int refreshAfter;
@@ -252,11 +247,11 @@ Future _apiRequest(String method, String path, dynamic data,
 `
 
 	tokensFileContentV2 = `class Tokens {
-  /// the token used to access, it must be carried in the header of each request
+  /// 用于访问的token, 每次请求都必须带在Header里面
   final String accessToken;
   final int accessExpire;
 
-  /// the token used to refresh
+  /// 用于刷新token
   final String refreshToken;
   final int refreshExpire;
   final int refreshAfter;

+ 1 - 1
tools/goctlwt/api/format/format_test.go

@@ -62,7 +62,7 @@ func TestFormat(t *testing.T) {
 }
 
 func Test_apiFormatReader_issue1721(t *testing.T) {
-	dir, err := os.MkdirTemp("", "goctl-api-format")
+	dir, err := os.MkdirTemp("", "goctlwt-api-format")
 	require.NoError(t, err)
 	defer os.RemoveAll(dir)
 	subDir := path.Join(dir, "sub")

+ 1 - 1
tools/goctlwt/api/gogen/gen.go

@@ -26,7 +26,7 @@ import (
 const tmpFile = "%s-%d"
 
 var (
-	tmpDir = path.Join(os.TempDir(), "goctl")
+	tmpDir = path.Join(os.TempDir(), "goctlwt")
 	// VarStringDir describes the directory.
 	VarStringDir string
 	// VarStringAPI describes the API.

+ 1 - 5
tools/goctlwt/api/gogen/gen_test.go

@@ -10,7 +10,6 @@ import (
 
 	"github.com/stretchr/testify/assert"
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/parser"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/env"
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/rpc/execx"
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/pathx"
 )
@@ -54,10 +53,7 @@ func TestParser(t *testing.T) {
 	filename := "greet.api"
 	err := os.WriteFile(filename, []byte(testApiTemplate), os.ModePerm)
 	assert.Nil(t, err)
-	env.Set(t, env.GoctlExperimental, "off")
-	t.Cleanup(func() {
-		os.Remove(filename)
-	})
+	defer os.Remove(filename)
 
 	api, err := parser.Parse(filename)
 	assert.Nil(t, err)

+ 1 - 1
tools/goctlwt/api/gogen/genroutes.go

@@ -21,7 +21,7 @@ import (
 const (
 	jwtTransKey    = "jwtTransition"
 	routesFilename = "routes"
-	routesTemplate = `// Code generated by goctl. DO NOT EDIT.
+	routesTemplate = `// Code generated by goctlwt. DO NOT EDIT.
 package handler
 
 import (

+ 1 - 1
tools/goctlwt/api/gogen/handler.tpl

@@ -3,7 +3,7 @@ package {{.PkgName}}
 import (
 	"net/http"
 
-	"github.com/wuntsong-org/go-zero-plus/rest/httpx"
+	"github.com/zeromicro/go-zero/rest/httpx"
 	{{.ImportPackages}}
 )
 

+ 1 - 1
tools/goctlwt/api/gogen/template.go

@@ -57,7 +57,7 @@ func RevertTemplate(name string) error {
 	return pathx.CreateTemplate(category, name, content)
 }
 
-// Update updates the template files to the templates built in current goctl.
+// Update updates the template files to the templates built in current goctlwt.
 func Update() error {
 	err := Clean()
 	if err != nil {

+ 1 - 1
tools/goctlwt/api/new/newservice.go

@@ -19,7 +19,7 @@ import (
 var apiTemplate string
 
 var (
-	// VarStringHome describes the goctl home.
+	// VarStringHome describes the goctlwt home.
 	VarStringHome string
 	// VarStringRemote describes the remote git repository.
 	VarStringRemote string

+ 1 - 1
tools/goctlwt/api/new/template.go

@@ -39,7 +39,7 @@ func RevertTemplate(name string) error {
 	return pathx.CreateTemplate(category, name, content)
 }
 
-// Update updates the template files to the templates built in current goctl.
+// Update updates the template files to the templates built in current goctlwt.
 func Update() error {
 	err := Clean()
 	if err != nil {

+ 0 - 1
tools/goctlwt/api/parser/g4/ast/apiparser.go

@@ -156,7 +156,6 @@ func (p *Parser) invokeImportedApi(filename string, imports []*ImportExpr) ([]*A
 		}
 		// ignore already imported file
 		if p.alreadyImported(impPath) {
-			p.importStatck.pop()
 			continue
 		}
 		p.fileMap[impPath] = PlaceHolder{}

+ 1 - 1
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser1.go

@@ -8,7 +8,7 @@ import (
 
 // Part 1
 // The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctl installation.
+// was too large and caused a possible memory overflow during goctlwt installation.
 
 func (s *SyntaxLitContext) STRING() antlr.TerminalNode {
 	return s.GetToken(ApiParserParserSTRING, 0)

+ 1 - 1
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser2.go

@@ -8,7 +8,7 @@ import (
 
 // Part 2
 // The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctl installation.
+// was too large and caused a possible memory overflow during goctlwt installation.
 
 type InfoSpecContext struct {
 	*antlr.BaseParserRuleContext

+ 1 - 1
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser3.go

@@ -8,7 +8,7 @@ import (
 
 // Part 3
 // The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctl installation.
+// was too large and caused a possible memory overflow during goctlwt installation.
 
 // ITypeBlockBodyContext is an interface to support dynamic dispatch.
 type ITypeBlockBodyContext interface {

+ 1 - 1
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser4.go

@@ -8,7 +8,7 @@ import (
 
 // Part 4
 // The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctl installation.
+// was too large and caused a possible memory overflow during goctlwt installation.
 
 // ITypeBlockAliasContext is an interface to support dynamic dispatch.
 type ITypeBlockAliasContext interface {

+ 1 - 1
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser5.go

@@ -8,7 +8,7 @@ import (
 
 // Part 5
 // The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctl installation.
+// was too large and caused a possible memory overflow during goctlwt installation.
 
 func (p *ApiParserParser) DataType() (localctx IDataTypeContext) {
 	localctx = NewDataTypeContext(p, p.GetParserRuleContext(), p.GetState())

+ 1 - 1
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser6.go

@@ -8,7 +8,7 @@ import (
 
 // Part 6
 // The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctl installation.
+// was too large and caused a possible memory overflow during goctlwt installation.
 
 type AtServerContext struct {
 	*antlr.BaseParserRuleContext

+ 1 - 1
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser7.go

@@ -8,7 +8,7 @@ import (
 
 // Part 7
 // The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctl installation.
+// was too large and caused a possible memory overflow during goctlwt installation.
 
 // IAtHandlerContext is an interface to support dynamic dispatch.
 type IAtHandlerContext interface {

+ 1 - 1
tools/goctlwt/api/parser/g4/gen/api/apiparser_parser8.go

@@ -9,7 +9,7 @@ import (
 
 // Part 8
 // The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctl installation.
+// was too large and caused a possible memory overflow during goctlwt installation.
 
 func (s *KvLitContext) Accept(visitor antlr.ParseTreeVisitor) any {
 	switch t := visitor.(type) {

+ 1 - 1
tools/goctlwt/api/parser/g4/gen/api/apiparser_visitor.go

@@ -1,4 +1,4 @@
-// Code generated from C:/Users/keson/GolandProjects/go-zero/tools/goctl/api/parser/g4\ApiParser.g4 by ANTLR 4.9. DO NOT EDIT.
+// Code generated from C:/Users/keson/GolandProjects/go-zero/tools/goctlwt/api/parser/g4\ApiParser.g4 by ANTLR 4.9. DO NOT EDIT.
 
 package api // ApiParser
 import "github.com/zeromicro/antlr"

+ 2 - 3
tools/goctlwt/api/parser/g4/gen/api/file_splitor_test.go

@@ -1,7 +1,7 @@
 // DO NOT EDIT.
 // Tool: split apiparser_parser.go
 // The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctl installation.
+// was too large and caused a possible memory overflow during goctlwt installation.
 package api
 
 import (
@@ -16,7 +16,6 @@ import (
 )
 
 func TestFileSplitor(t *testing.T) {
-	t.Skip("skip this test because it is used to split the apiparser_parser.go file by developer.")
 	dir := "."
 	data, err := os.ReadFile(filepath.Join(dir, "apiparser_parser.go"))
 	if err != nil {
@@ -42,7 +41,7 @@ import "github.com/zeromicro/antlr"
 
 // Part %s
 // The apiparser_parser.go file was split into multiple files because it
-// was too large and caused a possible memory overflow during goctl installation.
+// was too large and caused a possible memory overflow during goctlwt installation.
 `, part))
 		}
 

+ 8 - 12
tools/goctlwt/api/parser/parser.go

@@ -17,9 +17,7 @@ type parser struct {
 	spec *spec.ApiSpec
 }
 
-// Depreacted: use tools/goctl/pkg/parser/api/parser/parser.go:18 instead,
-// it will be removed in the future.
-// Parse parses the api file.
+// Parse parses the api file
 func Parse(filename string) (*spec.ApiSpec, error) {
 	if env.UseExperimental() {
 		return apiParser.Parse(filename, "")
@@ -63,15 +61,11 @@ func parseContent(content string, skipCheckTypeDeclaration bool, filename ...str
 	return apiSpec, nil
 }
 
-// Depreacted: use tools/goctl/pkg/parser/api/parser/parser.go:18 instead,
-// it will be removed in the future.
 // ParseContent parses the api content
 func ParseContent(content string, filename ...string) (*spec.ApiSpec, error) {
 	return parseContent(content, false, filename...)
 }
 
-// Depreacted: use tools/goctl/pkg/parser/api/parser/parser.go:18 instead,
-// it will be removed in the future.
 // ParseContentWithParserSkipCheckTypeDeclaration parses the api content with skip check type declaration
 func ParseContentWithParserSkipCheckTypeDeclaration(content string, filename ...string) (*spec.ApiSpec, error) {
 	return parseContent(content, true, filename...)
@@ -180,15 +174,17 @@ func (p parser) findDefinedType(name string) (*spec.Type, error) {
 }
 
 func (p parser) fieldToMember(field *ast.TypeField) spec.Member {
-	var name string
-	var tag string
+	name := ""
+	tag := ""
 	if !field.IsAnonymous {
 		name = field.Name.Text()
-		if field.Tag != nil {
-			tag = field.Tag.Text()
+		if field.Tag == nil {
+			panic(fmt.Sprintf("error: line %d:%d field %s has no tag",
+				field.Name.Line(), field.Name.Column(), field.Name.Text()))
 		}
-	}
 
+		tag = field.Tag.Text()
+	}
 	return spec.Member{
 		Name:     name,
 		Type:     p.astTypeToSpec(field.DataType),

+ 3 - 3
tools/goctlwt/bug/issue.go

@@ -3,14 +3,14 @@ package bug
 const issueTemplate = `
 <!-- Please answer these questions before submitting your issue. Thanks! -->
 
-### What category of issue (<code>goctl</code> or <code>sdk</code>)?
+### What category of issue (<code>goctlwt</code> or <code>sdk</code>)?
 
 ### What type of issue (<code>feature</code>|<code>bug</code>|<code>suggestion</code>)?
 
-### What version of Goctl are you using (<code>goctl --version</code>)?
+### What version of Goctl are you using (<code>goctlwt --version</code>)?
 
 <pre>
-$ goctl --version
+$ goctlwt --version
 %s
 </pre>
 

+ 1 - 1
tools/goctlwt/compare/cmd/cmd.go

@@ -8,7 +8,7 @@ import (
 
 var rootCmd = &cobra.Command{
 	Use:   "compare",
-	Short: "Compare the goctl commands generated results between urfave and cobra",
+	Short: "Compare the goctlwt commands generated results between urfave and cobra",
 	Args:  cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
 	Run: func(cmd *cobra.Command, args []string) {
 		dir := args[0]

+ 1 - 1
tools/goctlwt/compare/compare.go

@@ -2,7 +2,7 @@ package main
 
 import "github.com/wuntsong-org/go-zero-plus/tools/goctlwt/compare/cmd"
 
-// EXPERIMENTAL: compare goctl generated code results between old and new, it will be removed in the feature.
+// EXPERIMENTAL: compare goctlwt generated code results between old and new, it will be removed in the feature.
 // TODO: BEFORE RUNNING: export DSN=$datasource, the database must be gozero, and there has no limit for tables.
 // TODO: AFTER RUNNING: diff --recursive old_fs new_fs
 

+ 91 - 91
tools/goctlwt/compare/testdata/testcase.go

@@ -14,457 +14,457 @@ var (
 		{
 			IsDir: true,
 			Path:  "version",
-			Cmd:   "goctl --version",
+			Cmd:   "goctlwt --version",
 		},
 		{
 			IsDir: true,
 			Path:  "api/sample_file/local",
-			Cmd:   "goctl api --o sample.api",
+			Cmd:   "goctlwt api --o sample.api",
 		},
 		{
 			IsDir: true,
 			Path:  "api/sample_file/local/assign",
-			Cmd:   "goctl api --o=sample.api",
+			Cmd:   "goctlwt api --o=sample.api",
 		},
 		{
 			IsDir: true,
 			Path:  "api/sample_file/local/assign/shorthand",
-			Cmd:   "goctl api -o=sample.api",
+			Cmd:   "goctlwt api -o=sample.api",
 		},
 		{
 			IsDir: true,
 			Path:  "api/sample_file/remote",
-			Cmd:   "goctl api --o sample.api --remote https://github.com/wuntsong-org/go-zero-plus-template --branch main",
+			Cmd:   "goctlwt api --o sample.api --remote https://github.com/wuntsong-org/go-zero-plus-template --branch main",
 		},
 		{
 			IsDir: true,
 			Path:  "api/sample_file/remote/shorthand",
-			Cmd:   "goctl api -o sample.api -remote https://github.com/wuntsong-org/go-zero-plus-template -branch main",
+			Cmd:   "goctlwt api -o sample.api -remote https://github.com/wuntsong-org/go-zero-plus-template -branch main",
 		},
 		{
 			IsDir: true,
 			Path:  "api/sample_file/remote/assign",
-			Cmd:   "goctl api --o=sample.api --remote https://github.com/wuntsong-org/go-zero-plus-template --branch=main",
+			Cmd:   "goctlwt api --o=sample.api --remote https://github.com/wuntsong-org/go-zero-plus-template --branch=main",
 		},
 		{
 			IsDir: true,
 			Path:  "api/sample_file/remote/assign/shorthand",
-			Cmd:   "goctl api -o=sample.api -remote https://github.com/wuntsong-org/go-zero-plus-template -branch=main",
+			Cmd:   "goctlwt api -o=sample.api -remote https://github.com/wuntsong-org/go-zero-plus-template -branch=main",
 		},
 		{
 			IsDir: true,
 			Path:  "api/dart/legacy/true",
-			Cmd:   "goctl api --o sample.api && goctl api dart --api sample.api --dir . --hostname 127.0.0.1 --legacy true",
+			Cmd:   "goctlwt api --o sample.api && goctlwt api dart --api sample.api --dir . --hostname 127.0.0.1 --legacy true",
 		},
 		{
 			IsDir: true,
 			Path:  "api/dart/legacy/true/shorthand",
-			Cmd:   "goctl api -o sample.api && goctl api dart -api sample.api -dir . -hostname 127.0.0.1 -legacy true",
+			Cmd:   "goctlwt api -o sample.api && goctlwt api dart -api sample.api -dir . -hostname 127.0.0.1 -legacy true",
 		},
 		{
 			IsDir: true,
 			Path:  "api/dart/legacy/true/assign",
-			Cmd:   "goctl api --o=sample.api && goctl api dart --api=sample.api --dir=. --hostname=127.0.0.1 --legacy=true",
+			Cmd:   "goctlwt api --o=sample.api && goctlwt api dart --api=sample.api --dir=. --hostname=127.0.0.1 --legacy=true",
 		},
 		{
 			IsDir: true,
 			Path:  "api/dart/legacy/true/assign/shorthand",
-			Cmd:   "goctl api -o=sample.api && goctl api dart -api=sample.api -dir=. -hostname=127.0.0.1 -legacy=true",
+			Cmd:   "goctlwt api -o=sample.api && goctlwt api dart -api=sample.api -dir=. -hostname=127.0.0.1 -legacy=true",
 		},
 		{
 			IsDir: true,
 			Path:  "api/dart/legacy/false",
-			Cmd:   "goctl api --o sample.api && goctl api dart --api sample.api --dir . --hostname 127.0.0.1 --legacy true",
+			Cmd:   "goctlwt api --o sample.api && goctlwt api dart --api sample.api --dir . --hostname 127.0.0.1 --legacy true",
 		},
 		{
 			IsDir: true,
 			Path:  "api/dart/legacy/false/shorthand",
-			Cmd:   "goctl api -o sample.api && goctl api dart -api sample.api -dir . -hostname 127.0.0.1 -legacy true",
+			Cmd:   "goctlwt api -o sample.api && goctlwt api dart -api sample.api -dir . -hostname 127.0.0.1 -legacy true",
 		},
 		{
 			IsDir: true,
 			Path:  "api/dart/legacy/false/assign",
-			Cmd:   "goctl api --o=sample.api && goctl api dart --api=sample.api --dir=. --hostname=127.0.0.1 --legacy=true",
+			Cmd:   "goctlwt api --o=sample.api && goctlwt api dart --api=sample.api --dir=. --hostname=127.0.0.1 --legacy=true",
 		},
 		{
 			IsDir: true,
 			Path:  "api/dart/legacy/false/assign/shorthand",
-			Cmd:   "goctl api -o=sample.api && goctl api dart -api=sample.api -dir=. -hostname=127.0.0.1 -legacy=true",
+			Cmd:   "goctlwt api -o=sample.api && goctlwt api dart -api=sample.api -dir=. -hostname=127.0.0.1 -legacy=true",
 		},
 		{
 			IsDir: true,
 			Path:  "api/doc",
-			Cmd:   "goctl api --o sample.api && goctl api doc --dir . --o .",
+			Cmd:   "goctlwt api --o sample.api && goctlwt api doc --dir . --o .",
 		},
 		{
 			IsDir: true,
 			Path:  "api/doc/shorthand",
-			Cmd:   "goctl api -o sample.api && goctl api doc -dir . -o .",
+			Cmd:   "goctlwt api -o sample.api && goctlwt api doc -dir . -o .",
 		},
 		{
 			IsDir: true,
 			Path:  "api/doc/assign",
-			Cmd:   "goctl api --o=sample.api && goctl api doc --dir=. --o=.",
+			Cmd:   "goctlwt api --o=sample.api && goctlwt api doc --dir=. --o=.",
 		},
 		{
 			IsDir: true,
 			Path:  "api/doc/assign/shorthand",
-			Cmd:   "goctl api -o=sample.api && goctl api doc -dir=. -o=.",
+			Cmd:   "goctlwt api -o=sample.api && goctlwt api doc -dir=. -o=.",
 		},
 		{
 			Path:    "api/format/unformat.api",
 			Content: unformatApi,
-			Cmd:     "goctl api format --dir . --iu",
+			Cmd:     "goctlwt api format --dir . --iu",
 		},
 		{
 			Path:    "api/format/shorthand/unformat.api",
 			Content: unformatApi,
-			Cmd:     "goctl api format -dir . -iu",
+			Cmd:     "goctlwt api format -dir . -iu",
 		},
 		{
 			Path:    "api/format/assign/unformat.api",
 			Content: unformatApi,
-			Cmd:     "goctl api format --dir=. --iu",
+			Cmd:     "goctlwt api format --dir=. --iu",
 		},
 		{
 			Path:    "api/format/assign/shorthand/unformat.api",
 			Content: unformatApi,
-			Cmd:     "goctl api format -dir=. -iu",
+			Cmd:     "goctlwt api format -dir=. -iu",
 		},
 		{
 			IsDir: true,
 			Path:  "api/go/style/default",
-			Cmd:   "goctl api --o sample.api && goctl api go --api sample.api --dir .",
+			Cmd:   "goctlwt api --o sample.api && goctlwt api go --api sample.api --dir .",
 		},
 		{
 			IsDir: true,
 			Path:  "api/go/style/default/shorthand",
-			Cmd:   "goctl api -o sample.api && goctl api go -api sample.api -dir .",
+			Cmd:   "goctlwt api -o sample.api && goctlwt api go -api sample.api -dir .",
 		},
 		{
 			IsDir: true,
 			Path:  "api/go/style/assign/default",
-			Cmd:   "goctl api --o=sample.api && goctl api go --api=sample.api --dir=.",
+			Cmd:   "goctlwt api --o=sample.api && goctlwt api go --api=sample.api --dir=.",
 		},
 		{
 			IsDir: true,
 			Path:  "api/go/style/assign/default/shorthand",
-			Cmd:   "goctl api -o=sample.api && goctl api go -api=sample.api -dir=.",
+			Cmd:   "goctlwt api -o=sample.api && goctlwt api go -api=sample.api -dir=.",
 		},
 		{
 			IsDir: true,
 			Path:  "api/go/style/goZero",
-			Cmd:   "goctl api --o sample.api && goctl api go --api sample.api --dir . --style goZero",
+			Cmd:   "goctlwt api --o sample.api && goctlwt api go --api sample.api --dir . --style goZero",
 		},
 		{
 			IsDir: true,
 			Path:  "api/go/style/goZero/shorthand",
-			Cmd:   "goctl api -o sample.api && goctl api go -api sample.api -dir . -style goZero",
+			Cmd:   "goctlwt api -o sample.api && goctlwt api go -api sample.api -dir . -style goZero",
 		},
 		{
 			IsDir: true,
 			Path:  "api/go/style/goZero/assign",
-			Cmd:   "goctl api --o=sample.api && goctl api go --api=sample.api --dir=. --style=goZero",
+			Cmd:   "goctlwt api --o=sample.api && goctlwt api go --api=sample.api --dir=. --style=goZero",
 		},
 		{
 			IsDir: true,
 			Path:  "api/go/style/goZero/assign/shorthand",
-			Cmd:   "goctl api -o=sample.api && goctl api go -api=sample.api -dir=. -style=goZero",
+			Cmd:   "goctlwt api -o=sample.api && goctlwt api go -api=sample.api -dir=. -style=goZero",
 		},
 		{
 			IsDir: true,
 			Path:  "api/java",
-			Cmd:   "goctl api --o sample.api && goctl api java --api sample.api --dir .",
+			Cmd:   "goctlwt api --o sample.api && goctlwt api java --api sample.api --dir .",
 		},
 		{
 			IsDir: true,
 			Path:  "api/java/shorthand",
-			Cmd:   "goctl api -o sample.api && goctl api java -api sample.api -dir .",
+			Cmd:   "goctlwt api -o sample.api && goctlwt api java -api sample.api -dir .",
 		},
 		{
 			IsDir: true,
 			Path:  "api/java/assign",
-			Cmd:   "goctl api --o=sample.api && goctl api java --api=sample.api --dir=.",
+			Cmd:   "goctlwt api --o=sample.api && goctlwt api java --api=sample.api --dir=.",
 		},
 		{
 			IsDir: true,
 			Path:  "api/java/shorthand/assign",
-			Cmd:   "goctl api -o=sample.api && goctl api java -api=sample.api -dir=.",
+			Cmd:   "goctlwt api -o=sample.api && goctlwt api java -api=sample.api -dir=.",
 		},
 		{
 			IsDir: true,
 			Path:  "api/new/style/default",
-			Cmd:   "goctl api new greet",
+			Cmd:   "goctlwt api new greet",
 		},
 		{
 			IsDir: true,
 			Path:  "api/new/style/goZero",
-			Cmd:   "goctl api new greet --style goZero",
+			Cmd:   "goctlwt api new greet --style goZero",
 		},
 		{
 			IsDir: true,
 			Path:  "api/new/style/goZero/assign",
-			Cmd:   "goctl api new greet --style=goZero",
+			Cmd:   "goctlwt api new greet --style=goZero",
 		},
 		{
 			IsDir: true,
 			Path:  "api/new/style/goZero/shorthand",
-			Cmd:   "goctl api new greet -style goZero",
+			Cmd:   "goctlwt api new greet -style goZero",
 		},
 		{
 			IsDir: true,
 			Path:  "api/new/style/goZero/shorthand/assign",
-			Cmd:   "goctl api new greet -style=goZero",
+			Cmd:   "goctlwt api new greet -style=goZero",
 		},
 		{
 			IsDir: true,
 			Path:  "api/ts",
-			Cmd:   "goctl api --o sample.api && goctl api ts --api sample.api --dir . --unwrap --webapi .",
+			Cmd:   "goctlwt api --o sample.api && goctlwt api ts --api sample.api --dir . --unwrap --webapi .",
 		},
 		{
 			IsDir: true,
 			Path:  "api/ts/shorthand",
-			Cmd:   "goctl api -o sample.api && goctl api ts -api sample.api -dir . -unwrap -webapi .",
+			Cmd:   "goctlwt api -o sample.api && goctlwt api ts -api sample.api -dir . -unwrap -webapi .",
 		},
 		{
 			IsDir: true,
 			Path:  "api/ts/assign",
-			Cmd:   "goctl api --o=sample.api && goctl api ts --api=sample.api --dir=. --unwrap --webapi=.",
+			Cmd:   "goctlwt api --o=sample.api && goctlwt api ts --api=sample.api --dir=. --unwrap --webapi=.",
 		},
 		{
 			IsDir: true,
 			Path:  "api/ts/shorthand/assign",
-			Cmd:   "goctl api -o=sample.api && goctl api ts -api=sample.api -dir=. -unwrap -webapi=.",
+			Cmd:   "goctlwt api -o=sample.api && goctlwt api ts -api=sample.api -dir=. -unwrap -webapi=.",
 		},
 		{
 			IsDir: true,
 			Path:  "api/validate",
-			Cmd:   "goctl api --o sample.api && goctl api validate --api sample.api",
+			Cmd:   "goctlwt api --o sample.api && goctlwt api validate --api sample.api",
 		},
 		{
 			IsDir: true,
 			Path:  "api/validate/shorthand",
-			Cmd:   "goctl api -o sample.api && goctl api validate -api sample.api",
+			Cmd:   "goctlwt api -o sample.api && goctlwt api validate -api sample.api",
 		},
 		{
 			IsDir: true,
 			Path:  "api/validate/assign",
-			Cmd:   "goctl api --o=sample.api && goctl api validate --api=sample.api",
+			Cmd:   "goctlwt api --o=sample.api && goctlwt api validate --api=sample.api",
 		},
 		{
 			IsDir: true,
 			Path:  "api/validate/shorthand/assign",
-			Cmd:   "goctl api -o=sample.api && goctl api validate -api=sample.api",
+			Cmd:   "goctlwt api -o=sample.api && goctlwt api validate -api=sample.api",
 		},
 		{
 			IsDir: true,
 			Path:  "env/show",
-			Cmd:   "goctl env > env.txt",
+			Cmd:   "goctlwt env > env.txt",
 		},
 		{
 			IsDir: true,
 			Path:  "env/check",
-			Cmd:   "goctl env check -f -v",
+			Cmd:   "goctlwt env check -f -v",
 		},
 		{
 			IsDir: true,
 			Path:  "env/install",
-			Cmd:   "goctl env install -v",
+			Cmd:   "goctlwt env install -v",
 		},
 		{
 			IsDir: true,
 			Path:  "kube",
-			Cmd:   "goctl kube deploy --image alpine --name foo --namespace foo --o foo.yaml --port 8888",
+			Cmd:   "goctlwt kube deploy --image alpine --name foo --namespace foo --o foo.yaml --port 8888",
 		},
 		{
 			IsDir: true,
 			Path:  "kube/shorthand",
-			Cmd:   "goctl kube deploy -image alpine -name foo -namespace foo -o foo.yaml -port 8888",
+			Cmd:   "goctlwt kube deploy -image alpine -name foo -namespace foo -o foo.yaml -port 8888",
 		},
 		{
 			IsDir: true,
 			Path:  "kube/assign",
-			Cmd:   "goctl kube deploy --image=alpine --name=foo --namespace=foo --o=foo.yaml --port=8888",
+			Cmd:   "goctlwt kube deploy --image=alpine --name=foo --namespace=foo --o=foo.yaml --port=8888",
 		},
 		{
 			IsDir: true,
 			Path:  "kube/shorthand/assign",
-			Cmd:   "goctl kube deploy -image=alpine -name=foo -namespace=foo -o=foo.yaml -port=8888",
+			Cmd:   "goctlwt kube deploy -image=alpine -name=foo -namespace=foo -o=foo.yaml -port=8888",
 		},
 		{
 			IsDir: true,
 			Path:  "model/mongo/cache",
-			Cmd:   "goctl model mongo --dir . --type user --style goZero -c",
+			Cmd:   "goctlwt model mongo --dir . --type user --style goZero -c",
 		},
 		{
 			IsDir: true,
 			Path:  "model/mongo/cache/shorthand",
-			Cmd:   "goctl model mongo -dir . -type user -style goZero -c",
+			Cmd:   "goctlwt model mongo -dir . -type user -style goZero -c",
 		},
 		{
 			IsDir: true,
 			Path:  "model/mongo/cache/assign",
-			Cmd:   "goctl model mongo --dir=. --type=user --style=goZero -c",
+			Cmd:   "goctlwt model mongo --dir=. --type=user --style=goZero -c",
 		},
 		{
 			IsDir: true,
 			Path:  "model/mongo/cache/shorthand/assign",
-			Cmd:   "goctl model mongo -dir=. -type=user -style=goZero -c",
+			Cmd:   "goctlwt model mongo -dir=. -type=user -style=goZero -c",
 		},
 		{
 			IsDir: true,
 			Path:  "model/mongo/nocache",
-			Cmd:   "goctl model mongo --dir . --type user",
+			Cmd:   "goctlwt model mongo --dir . --type user",
 		},
 		{
 			IsDir: true,
 			Path:  "model/mongo/nocache/shorthand",
-			Cmd:   "goctl model mongo -dir . -type user",
+			Cmd:   "goctlwt model mongo -dir . -type user",
 		},
 		{
 			IsDir: true,
 			Path:  "model/mongo/nocache/assign",
-			Cmd:   "goctl model mongo --dir=. --type=user",
+			Cmd:   "goctlwt model mongo --dir=. --type=user",
 		},
 		{
 			IsDir: true,
 			Path:  "model/mongo/nocache/shorthand/assign",
-			Cmd:   "goctl model mongo -dir=. -type=user",
+			Cmd:   "goctlwt model mongo -dir=. -type=user",
 		},
 		{
 			Content: userSql,
 			Path:    "model/mysql/ddl/user.sql",
-			Cmd:     "goctl model mysql ddl --database user --dir cache --src user.sql -c",
+			Cmd:     "goctlwt model mysql ddl --database user --dir cache --src user.sql -c",
 		},
 		{
 			Content: userSql,
 			Path:    "model/mysql/ddl/shorthand/user.sql",
-			Cmd:     "goctl model mysql ddl -database user -dir cache -src user.sql -c",
+			Cmd:     "goctlwt model mysql ddl -database user -dir cache -src user.sql -c",
 		},
 		{
 			Content: userSql,
 			Path:    "model/mysql/ddl/assign/user.sql",
-			Cmd:     "goctl model mysql ddl --database=user --dir=cache --src=user.sql -c",
+			Cmd:     "goctlwt model mysql ddl --database=user --dir=cache --src=user.sql -c",
 		},
 		{
 			Content: userSql,
 			Path:    "model/mysql/ddl/shorthand/assign/user.sql",
-			Cmd:     "goctl model mysql ddl -database=user -dir=cache -src=user.sql -c",
+			Cmd:     "goctlwt model mysql ddl -database=user -dir=cache -src=user.sql -c",
 		},
 		{
 			Content: userSql,
 			Path:    "model/mysql/ddl/user.sql",
-			Cmd:     "goctl model mysql ddl --database user --dir nocache --src user.sql",
+			Cmd:     "goctlwt model mysql ddl --database user --dir nocache --src user.sql",
 		},
 		{
 			Content: userSql,
 			Path:    "model/mysql/ddl/shorthand/user.sql",
-			Cmd:     "goctl model mysql ddl -database user -dir nocache -src user.sql",
+			Cmd:     "goctlwt model mysql ddl -database user -dir nocache -src user.sql",
 		},
 		{
 			Content: userSql,
 			Path:    "model/mysql/ddl/assign/user.sql",
-			Cmd:     "goctl model mysql ddl --database=user --dir=nocache --src=user.sql",
+			Cmd:     "goctlwt model mysql ddl --database=user --dir=nocache --src=user.sql",
 		},
 		{
 			Content: userSql,
 			Path:    "model/mysql/ddl/shorthand/assign/user.sql",
-			Cmd:     "goctl model mysql ddl -database=user -dir=nocache -src=user.sql",
+			Cmd:     "goctlwt model mysql ddl -database=user -dir=nocache -src=user.sql",
 		},
 		{
 			IsDir: true,
 			Path:  "model/mysql/datasource",
-			Cmd:   `goctl model mysql datasource --url $DSN --dir cache --table "*" -c`,
+			Cmd:   `goctlwt model mysql datasource --url $DSN --dir cache --table "*" -c`,
 		},
 		{
 			IsDir: true,
 			Path:  "model/mysql/datasource/shorthand",
-			Cmd:   `goctl model mysql datasource -url $DSN -dir cache -table "*" -c`,
+			Cmd:   `goctlwt model mysql datasource -url $DSN -dir cache -table "*" -c`,
 		},
 		{
 			IsDir: true,
 			Path:  "model/mysql/datasource/shorthand2",
-			Cmd:   `goctl model mysql datasource -url $DSN -dir cache -t "*" -c`,
+			Cmd:   `goctlwt model mysql datasource -url $DSN -dir cache -t "*" -c`,
 		},
 		{
 			IsDir: true,
 			Path:  "model/mysql/datasource/assign",
-			Cmd:   `goctl model mysql datasource --url=$DSN --dir=cache --table="*" -c`,
+			Cmd:   `goctlwt model mysql datasource --url=$DSN --dir=cache --table="*" -c`,
 		},
 		{
 			IsDir: true,
 			Path:  "model/mysql/datasource/shorthand/assign",
-			Cmd:   `goctl model mysql datasource -url=$DSN -dir=cache -table="*" -c`,
+			Cmd:   `goctlwt model mysql datasource -url=$DSN -dir=cache -table="*" -c`,
 		},
 		{
 			IsDir: true,
 			Path:  "model/mysql/datasource/shorthand2/assign",
-			Cmd:   `goctl model mysql datasource -url=$DSN -dir=cache -t="*" -c`,
+			Cmd:   `goctlwt model mysql datasource -url=$DSN -dir=cache -t="*" -c`,
 		},
 		{
 			IsDir: true,
 			Path:  "model/mysql/datasource",
-			Cmd:   `goctl model mysql datasource --url $DSN --dir nocache --table "*" -c`,
+			Cmd:   `goctlwt model mysql datasource --url $DSN --dir nocache --table "*" -c`,
 		},
 		{
 			IsDir: true,
 			Path:  "model/mysql/datasource/shorthand",
-			Cmd:   `goctl model mysql datasource -url $DSN -dir nocache -table "*" -c`,
+			Cmd:   `goctlwt model mysql datasource -url $DSN -dir nocache -table "*" -c`,
 		},
 		{
 			IsDir: true,
 			Path:  "model/mysql/datasource/shorthand2",
-			Cmd:   `goctl model mysql datasource -url $DSN -dir nocache -t "*" -c`,
+			Cmd:   `goctlwt model mysql datasource -url $DSN -dir nocache -t "*" -c`,
 		},
 		{
 			IsDir: true,
 			Path:  "model/mysql/datasource/assign",
-			Cmd:   `goctl model mysql datasource --url=$DSN --dir=nocache --table="*" -c`,
+			Cmd:   `goctlwt model mysql datasource --url=$DSN --dir=nocache --table="*" -c`,
 		},
 		{
 			IsDir: true,
 			Path:  "model/mysql/datasource/shorthand/assign",
-			Cmd:   `goctl model mysql datasource -url=$DSN -dir=nocache -table="*" -c`,
+			Cmd:   `goctlwt model mysql datasource -url=$DSN -dir=nocache -table="*" -c`,
 		},
 		{
 			IsDir: true,
 			Path:  "model/mysql/datasource/shorthand2/assign",
-			Cmd:   `goctl model mysql datasource -url=$DSN -dir=nocache -t="*" -c`,
+			Cmd:   `goctlwt model mysql datasource -url=$DSN -dir=nocache -t="*" -c`,
 		},
 		{
 			IsDir: true,
 			Path:  "rpc/new",
-			Cmd:   "goctl rpc new greet",
+			Cmd:   "goctlwt rpc new greet",
 		},
 		{
 			IsDir: true,
 			Path:  "rpc/template",
-			Cmd:   "goctl rpc template --o greet.proto",
+			Cmd:   "goctlwt rpc template --o greet.proto",
 		},
 		{
 			IsDir: true,
 			Path:  "rpc/template/shorthand",
-			Cmd:   "goctl rpc template -o greet.proto",
+			Cmd:   "goctlwt rpc template -o greet.proto",
 		},
 		{
 			IsDir: true,
 			Path:  "rpc/template/assign",
-			Cmd:   "goctl rpc template --o=greet.proto",
+			Cmd:   "goctlwt rpc template --o=greet.proto",
 		},
 		{
 			IsDir: true,
 			Path:  "rpc/template/shorthand/assign",
-			Cmd:   "goctl rpc template -o=greet.proto",
+			Cmd:   "goctlwt rpc template -o=greet.proto",
 		},
 		{
 			IsDir: true,
 			Path:  "rpc/protoc",
-			Cmd:   "goctl rpc template --o greet.proto && goctl rpc protoc greet.proto --go_out . --go-grpc_out . --zrpc_out .",
+			Cmd:   "goctlwt rpc template --o greet.proto && goctlwt rpc protoc greet.proto --go_out . --go-grpc_out . --zrpc_out .",
 		},
 		{
 			IsDir: true,
 			Path:  "rpc/protoc/assign",
-			Cmd:   "goctl rpc template --o=greet.proto && goctl rpc protoc greet.proto --go_out=. --go-grpc_out=. --zrpc_out=.",
+			Cmd:   "goctlwt rpc template --o=greet.proto && goctlwt rpc protoc greet.proto --go_out=. --go-grpc_out=. --zrpc_out=.",
 		},
 	}
 )

+ 6 - 6
tools/goctlwt/compare/testdata/testdata.go

@@ -31,8 +31,8 @@ func (f File) execute(goctl string) error {
 		printDir = filepath.Dir(printDir)
 		dir = filepath.Dir(dir)
 	}
-	printCommand := strings.ReplaceAll(fmt.Sprintf("cd %s && %s", printDir, f.Cmd), "goctl", filepath.Base(goctl))
-	command := strings.ReplaceAll(fmt.Sprintf("cd %s && %s", dir, f.Cmd), "goctl", goctl)
+	printCommand := strings.ReplaceAll(fmt.Sprintf("cd %s && %s", printDir, f.Cmd), "goctlwt", filepath.Base(goctl))
+	command := strings.ReplaceAll(fmt.Sprintf("cd %s && %s", dir, f.Cmd), "goctlwt", goctl)
 	fmt.Println(color.LightGreen.Render(printCommand))
 	cmd := exec.Command("sh", "-c", command)
 	cmd.Env = os.Environ()
@@ -101,14 +101,14 @@ func mustGetTestData(baseDir string) (Files, Files) {
 
 func MustRun(baseDir string) {
 	oldFiles, newFiles := mustGetTestData(baseDir)
-	goctlOld, err := exec.LookPath("goctl.old")
+	goctlOld, err := exec.LookPath("goctlwt.old")
 	must(err)
-	goctlNew, err := exec.LookPath("goctl")
+	goctlNew, err := exec.LookPath("goctlwt")
 	must(err)
-	fmt.Println(color.LightBlue.Render("========================goctl.old======================="))
+	fmt.Println(color.LightBlue.Render("========================goctlwt.old======================="))
 	must(oldFiles.execute(goctlOld))
 	fmt.Println()
-	fmt.Println(color.LightBlue.Render("========================goctl.new======================="))
+	fmt.Println(color.LightBlue.Render("========================goctlwt.new======================="))
 	must(newFiles.execute(goctlNew))
 }
 

+ 3 - 3
tools/goctlwt/config/readme.md

@@ -37,13 +37,13 @@
 # 使用方法
 目前可通过在生成api、rpc、model时通过`--style`参数指定format格式,如:
 ```shell script
-goctl api go test.api -dir . -style gozero
+goctlwt api go test.api -dir . -style gozero
 ```
 ```shell script
- goctl rpc proto -src test.proto -dir . -style go_zero
+ goctlwt rpc proto -src test.proto -dir . -style go_zero
 ```
 ```shell script
-goctl model mysql datasource -url="" -table="*" -dir ./snake -style GoZero
+goctlwt model mysql datasource -url="" -table="*" -dir ./snake -style GoZero
 ```
 
 # 默认值

+ 1 - 1
tools/goctlwt/docker/docker.go

@@ -38,7 +38,7 @@ type Docker struct {
 	Timezone    string
 }
 
-// dockerCommand provides the entry for goctl docker
+// dockerCommand provides the entry for goctlwt docker
 func dockerCommand(_ *cobra.Command, _ []string) (err error) {
 	defer func() {
 		if err == nil {

+ 14 - 14
tools/goctlwt/env/check.go

@@ -44,46 +44,46 @@ func check(_ *cobra.Command, _ []string) error {
 func Prepare(install, force, verbose bool) error {
 	log := console.NewColorConsole(verbose)
 	pending := true
-	log.Info("[goctl-env]: preparing to check env")
+	log.Info("[goctlwt-env]: preparing to check env")
 	defer func() {
 		if p := recover(); p != nil {
 			log.Error("%+v", p)
 			return
 		}
 		if pending {
-			log.Success("\n[goctl-env]: congratulations! your goctl environment is ready!")
+			log.Success("\n[goctlwt-env]: congratulations! your goctlwt environment is ready!")
 		} else {
 			log.Error(`
-[goctl-env]: check env finish, some dependencies is not found in PATH, you can execute
-command 'goctl env check --install' to install it, for details, please execute command 
-'goctl env check --help'`)
+[goctlwt-env]: check env finish, some dependencies is not found in PATH, you can execute
+command 'goctlwt env check --install' to install it, for details, please execute command 
+'goctlwt env check --help'`)
 		}
 	}()
 	for _, e := range bins {
 		time.Sleep(200 * time.Millisecond)
 		log.Info("")
-		log.Info("[goctl-env]: looking up %q", e.name)
+		log.Info("[goctlwt-env]: looking up %q", e.name)
 		if e.exists {
-			log.Success("[goctl-env]: %q is installed", e.name)
+			log.Success("[goctlwt-env]: %q is installed", e.name)
 			continue
 		}
-		log.Warning("[goctl-env]: %q is not found in PATH", e.name)
+		log.Warning("[goctlwt-env]: %q is not found in PATH", e.name)
 		if install {
 			install := func() {
-				log.Info("[goctl-env]: preparing to install %q", e.name)
+				log.Info("[goctlwt-env]: preparing to install %q", e.name)
 				path, err := e.get(env.Get(env.GoctlCache))
 				if err != nil {
-					log.Error("[goctl-env]: an error interrupted the installation: %+v", err)
+					log.Error("[goctlwt-env]: an error interrupted the installation: %+v", err)
 					pending = false
 				} else {
-					log.Success("[goctl-env]: %q is already installed in %q", e.name, path)
+					log.Success("[goctlwt-env]: %q is already installed in %q", e.name, path)
 				}
 			}
 			if force {
 				install()
 				continue
 			}
-			console.Info("[goctl-env]: do you want to install %q [y: YES, n: No]", e.name)
+			console.Info("[goctlwt-env]: do you want to install %q [y: YES, n: No]", e.name)
 			for {
 				var in string
 				fmt.Scanln(&in)
@@ -94,10 +94,10 @@ command 'goctl env check --install' to install it, for details, please execute c
 					brk = true
 				case strings.EqualFold(in, "n"):
 					pending = false
-					console.Info("[goctl-env]: %q installation is ignored", e.name)
+					console.Info("[goctlwt-env]: %q installation is ignored", e.name)
 					brk = true
 				default:
-					console.Error("[goctl-env]: invalid input, input 'y' for yes, 'n' for no")
+					console.Error("[goctlwt-env]: invalid input, input 'y' for yes, 'n' for no")
 				}
 				if brk {
 					break

+ 1 - 1
tools/goctlwt/example/rpc/hello/client/greet/greet.go

@@ -1,4 +1,4 @@
-// Code generated by goctl. DO NOT EDIT!
+// Code generated by goctlwt. DO NOT EDIT!
 // Source: hello.proto
 
 package client

+ 1 - 1
tools/goctlwt/example/rpc/hello/internal/server/greet/greetserver.go

@@ -1,4 +1,4 @@
-// Code generated by goctl. DO NOT EDIT!
+// Code generated by goctlwt. DO NOT EDIT!
 // Source: hello.proto
 
 package server

+ 1 - 1
tools/goctlwt/example/rpc/hi/client/event/event.go

@@ -1,4 +1,4 @@
-// Code generated by goctl. DO NOT EDIT!
+// Code generated by goctlwt. DO NOT EDIT!
 // Source: hi.proto
 
 package client

+ 1 - 1
tools/goctlwt/example/rpc/hi/client/greet/greet.go

@@ -1,4 +1,4 @@
-// Code generated by goctl. DO NOT EDIT!
+// Code generated by goctlwt. DO NOT EDIT!
 // Source: hi.proto
 
 package client

+ 1 - 1
tools/goctlwt/example/rpc/hi/internal/server/event/eventserver.go

@@ -1,4 +1,4 @@
-// Code generated by goctl. DO NOT EDIT!
+// Code generated by goctlwt. DO NOT EDIT!
 // Source: hi.proto
 
 package server

+ 1 - 1
tools/goctlwt/example/rpc/hi/internal/server/greet/greetserver.go

@@ -1,4 +1,4 @@
-// Code generated by goctl. DO NOT EDIT!
+// Code generated by goctlwt. DO NOT EDIT!
 // Source: hi.proto
 
 package server

+ 2 - 2
tools/goctlwt/gateway/gateway.tpl

@@ -3,8 +3,8 @@ package main
 import (
 	"flag"
 
-	"github.com/wuntsong-org/go-zero-plus/core/conf"
-	"github.com/wuntsong-org/go-zero-plus/gateway"
+	"github.com/zeromicro/go-zero/core/conf"
+	"github.com/zeromicro/go-zero/gateway"
 )
 
 var configFile = flag.String("f", "etc/gateway.yaml", "config file")

+ 1 - 1
tools/goctlwt/gateway/template.go

@@ -24,7 +24,7 @@ var templates = map[string]string{
 	mainTemplateFile:    mainTemplate,
 }
 
-// GenTemplates is the entry for command goctl template,
+// GenTemplates is the entry for command goctlwt template,
 // it will create the specified category
 func GenTemplates() error {
 	return pathx.InitTemplates(category, templates)

+ 5 - 5
tools/goctlwt/go.mod

@@ -1,4 +1,4 @@
-module github.com/wuntsong-org/go-zero-plus/tools/goctlwtwt
+module github.com/wuntsong-org/go-zero-plus/tools/goctlwt
 
 go 1.21
 
@@ -6,17 +6,16 @@ toolchain go1.21.0
 
 require (
 	github.com/DATA-DOG/go-sqlmock v1.5.0
-	github.com/emicklei/proto v1.12.2
+	github.com/emicklei/proto v1.12.1
 	github.com/fatih/structtag v1.2.0
 	github.com/go-sql-driver/mysql v1.7.1
 	github.com/gookit/color v1.5.4
 	github.com/iancoleman/strcase v0.3.0
-	github.com/spf13/cobra v1.8.0
+	github.com/spf13/cobra v1.7.0
 	github.com/spf13/pflag v1.0.5
 	github.com/stretchr/testify v1.8.4
 	github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1
-	github.com/wuntsong-org/go-zero-plus v1.5.0
-	github.com/wuntsong-org/go-zero-plus/tools/goctlwt v0.0.0-20231214074533-4b2d014bef4f
+	github.com/wuntsong-org/go-zero-plus v1.7.0
 	github.com/zeromicro/antlr v0.0.1
 	github.com/zeromicro/ddl-parser v1.0.5
 	golang.org/x/text v0.14.0
@@ -37,6 +36,7 @@ require (
 	github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
 	github.com/emicklei/go-restful/v3 v3.11.0 // indirect
 	github.com/fatih/color v1.16.0 // indirect
+	github.com/fsnotify/fsnotify v1.6.0 // indirect
 	github.com/go-logr/logr v1.3.0 // indirect
 	github.com/go-logr/stdr v1.2.2 // indirect
 	github.com/go-openapi/jsonpointer v0.19.6 // indirect

+ 8 - 9
tools/goctlwt/go.sum

@@ -23,7 +23,7 @@ github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr
 github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
 github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
 github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
-github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
+github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
 github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
 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=
@@ -32,8 +32,8 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
 github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
 github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
 github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
-github.com/emicklei/proto v1.12.2 h1:ZDyDzrfMt7ncmyor/j07uoOCGLKtU5F87vTPwIzLe/o=
-github.com/emicklei/proto v1.12.2/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A=
+github.com/emicklei/proto v1.12.1 h1:6n/Z2pZAnBwuhU66Gs8160B8rrrYKo7h2F2sCOnNceE=
+github.com/emicklei/proto v1.12.1/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A=
 github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
 github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
 github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
@@ -164,8 +164,8 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj
 github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
 github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
 github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
-github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
-github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
+github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
+github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
 github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
 github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -181,10 +181,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
 github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
 github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1 h1:+dBg5k7nuTE38VVdoroRsT0Z88fmvdYrI2EjzJst35I=
 github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1/go.mod h1:nmuySobZb4kFgFy6BptpXp/BBw+xFSyvVPP6auoJB4k=
-github.com/wuntsong-org/go-zero-plus v1.5.0 h1:rTXMvRUN9x47ejeTxQzGqB/ZFSwgNEbYledwh5k5PFY=
-github.com/wuntsong-org/go-zero-plus v1.5.0/go.mod h1:vbITb92SYHhIF1ME6c2OTCjF9Mny4TsQZvxw2oDBVTg=
-github.com/wuntsong-org/go-zero-plus/tools/goctlwt v0.0.0-20231214074533-4b2d014bef4f h1:NAWv3LgWQ2PoX08dCLMZ6G1muba1ZjE2ijavsb+2arE=
-github.com/wuntsong-org/go-zero-plus/tools/goctlwt v0.0.0-20231214074533-4b2d014bef4f/go.mod h1:JJkghDb6Cgw3BmDdeRPdJUcLSeVnWCPnRO2i9bmA3Ag=
+github.com/wuntsong-org/go-zero-plus v1.7.0 h1:tO9yXpmB6nw5LnYL1g0j2OcTCPRYIKWtw/q58mEqJx8=
+github.com/wuntsong-org/go-zero-plus v1.7.0/go.mod h1:Qs2f4ir+eG+4jB1iqnv00QJ9h2iM87TAZZhQgLugaUg=
 github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8=
 github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
 github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -275,6 +273,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
 golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=

+ 1 - 1
tools/goctlwt/goctlwt.go

@@ -3,7 +3,7 @@ package main
 import (
 	"github.com/wuntsong-org/go-zero-plus/core/load"
 	"github.com/wuntsong-org/go-zero-plus/core/logx"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwtwt/cmd"
+	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/cmd"
 )
 
 func main() {

+ 4 - 4
tools/goctlwt/internal/errorx/errorx.go

@@ -7,12 +7,12 @@ import (
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/env"
 )
 
-var errorFormat = `goctl error: %+v
-goctl env:
+var errorFormat = `goctlwt error: %+v
+goctlwt env:
 %s
 %s`
 
-// GoctlError represents a goctl error.
+// GoctlError represents a goctlwt error.
 type GoctlError struct {
 	message []string
 	err     error
@@ -23,7 +23,7 @@ func (e *GoctlError) Error() string {
 	return fmt.Sprintf(errorFormat, e.err, env.Print(), detail)
 }
 
-// Wrap wraps an error with goctl version and message.
+// Wrap wraps an error with goctlwt version and message.
 func Wrap(err error, message ...string) error {
 	e, ok := err.(*GoctlError)
 	if ok {

+ 4 - 4
tools/goctlwt/internal/version/version.go

@@ -5,8 +5,8 @@ import (
 	"strings"
 )
 
-// BuildVersion is the version of goctl.
-const BuildVersion = "1.6.0"
+// BuildVersion is the version of goctlwt.
+const BuildVersion = "1.5.5"
 
 var tag = map[string]int{"pre-alpha": 0, "alpha": 1, "pre-bata": 2, "beta": 3, "released": 4, "": 5}
 
@@ -15,7 +15,7 @@ func GetGoctlVersion() string {
 	return BuildVersion
 }
 
-// IsVersionGreaterThan compares whether the current goctl version
+// IsVersionGreaterThan compares whether the current goctlwt version
 // is greater than the target version
 func IsVersionGreaterThan(version, target string) bool {
 	versionNumber, versionTag := convertVersion(version)
@@ -25,7 +25,7 @@ func IsVersionGreaterThan(version, target string) bool {
 	} else if versionNumber < targetVersionNumber {
 		return false
 	} else {
-		// unchecked case, in normal, the goctl version does not contain suffix in release.
+		// unchecked case, in normal, the goctlwt version does not contain suffix in release.
 		return tag[versionTag] > tag[targetTag]
 	}
 }

+ 1 - 1
tools/goctlwt/kube/kube.go

@@ -138,7 +138,7 @@ func RevertTemplate(name string) error {
 	return pathx.CreateTemplate(category, name, deploymentTemplate)
 }
 
-// Update updates the template files to the templates built in current goctl.
+// Update updates the template files to the templates built in current goctlwt.
 func Update() error {
 	err := Clean()
 	if err != nil {

+ 1 - 1
tools/goctlwt/migrate/mod.go

@@ -14,7 +14,7 @@ import (
 
 const (
 	deprecatedGoZeroMod = "github.com/tal-tech/go-zero"
-	deprecatedBuilderx  = "github.com/tal-tech/go-zero/tools/goctl/model/sql/builderx"
+	deprecatedBuilderx  = "github.com/tal-tech/go-zero/tools/goctlwt/model/sql/builderx"
 	replacementBuilderx = "github.com/wuntsong-org/go-zero-plus/core/stores/builder"
 	goZeroMod           = "github.com/wuntsong-org/go-zero-plus"
 )

+ 2 - 5
tools/goctlwt/model/cmd.go

@@ -46,7 +46,7 @@ func init() {
 	datasourceCmdFlags.StringVar(&command.VarStringBranch, "branch")
 
 	pgDatasourceCmdFlags.StringVar(&command.VarStringURL, "url")
-	pgDatasourceCmdFlags.StringSliceVarP(&command.VarStringSliceTable, "table", "t")
+	pgDatasourceCmdFlags.StringVarP(&command.VarStringTable, "table", "t")
 	pgDatasourceCmdFlags.StringVarPWithDefaultValue(&command.VarStringSchema, "schema", "s", "public")
 	pgDatasourceCmdFlags.BoolVarP(&command.VarBoolCache, "cache", "c")
 	pgDatasourceCmdFlags.StringVarP(&command.VarStringDir, "dir", "d")
@@ -56,8 +56,6 @@ func init() {
 	pgDatasourceCmdFlags.StringVar(&command.VarStringHome, "home")
 	pgDatasourceCmdFlags.StringVar(&command.VarStringRemote, "remote")
 	pgDatasourceCmdFlags.StringVar(&command.VarStringBranch, "branch")
-	pgCmd.PersistentFlags().StringSliceVarPWithDefaultValue(&command.VarStringSliceIgnoreColumns,
-		"ignore-columns", "i", []string{"create_at", "created_at", "create_time", "update_at", "updated_at", "update_time"})
 
 	mongoCmdFlags.StringSliceVarP(&mongo.VarStringSliceType, "type", "t")
 	mongoCmdFlags.BoolVarP(&mongo.VarBoolCache, "cache", "c")
@@ -69,8 +67,7 @@ func init() {
 	mongoCmdFlags.StringVar(&mongo.VarStringBranch, "branch")
 
 	mysqlCmd.PersistentFlags().BoolVar(&command.VarBoolStrict, "strict")
-	mysqlCmd.PersistentFlags().StringSliceVarPWithDefaultValue(&command.VarStringSliceIgnoreColumns,
-		"ignore-columns", "i", []string{"create_at", "created_at", "create_time", "update_at", "updated_at", "update_time"})
+	mysqlCmd.PersistentFlags().StringSliceVarPWithDefaultValue(&command.VarStringSliceIgnoreColumns, "ignore-columns", "i", []string{"create_at", "created_at", "create_time", "update_at", "updated_at", "update_time"})
 
 	mysqlCmd.AddCommand(datasourceCmd, ddlCmd)
 	pgCmd.AddCommand(pgDatasourceCmd)

+ 2 - 2
tools/goctlwt/model/mongo/mongo.go

@@ -23,7 +23,7 @@ var (
 	VarBoolEasy bool
 	// VarStringStyle describes the style.
 	VarStringStyle string
-	// VarStringHome describes the goctl home.
+	// VarStringHome describes the goctlwt home.
 	VarStringHome string
 	// VarStringRemote describes the remote git repository.
 	VarStringRemote string
@@ -31,7 +31,7 @@ var (
 	VarStringBranch string
 )
 
-// Action provides the entry for goctl mongo code generation.
+// Action provides the entry for goctlwt mongo code generation.
 func Action(_ *cobra.Command, _ []string) error {
 	tp := VarStringSliceType
 	c := VarBoolCache

+ 2 - 2
tools/goctlwt/model/mongo/readme.md

@@ -17,7 +17,7 @@ mongo的生成不同于mysql,mysql可以从scheme_information库中读取到
 ## 使用示例
 为 User 生成 mongo model
 ```bash
-$ goctl model mongo -t User -c --dir .
+$ goctlwt model mongo -t User -c --dir .
 ```
 
 ### 生成示例代码
@@ -57,7 +57,7 @@ func NewUserModel(url, db, collection string, c cache.CacheConf) UserModel {
 
 #### usermodelgen.go
 ```go
-// Code generated by goctl. DO NOT EDIT.
+// Code generated by goctlwt. DO NOT EDIT.
 package model
 
 import (

+ 1 - 1
tools/goctlwt/model/mongo/template/error.tpl

@@ -3,7 +3,7 @@ package model
 import (
 	"errors"
 
-	"github.com/wuntsong-org/go-zero-plus/core/stores/mon"
+	"github.com/zeromicro/go-zero/core/stores/mon"
 )
 
 var (

+ 1 - 1
tools/goctlwt/model/mongo/template/model.tpl

@@ -5,7 +5,7 @@ import (
     "context"
     "time"
 
-    {{if .Cache}}"github.com/wuntsong-org/go-zero-plus/core/stores/monc"{{else}}"github.com/wuntsong-org/go-zero-plus/core/stores/mon"{{end}}
+    {{if .Cache}}"github.com/zeromicro/go-zero/core/stores/monc"{{else}}"github.com/zeromicro/go-zero/core/stores/mon"{{end}}
     "go.mongodb.org/mongo-driver/bson"
     "go.mongodb.org/mongo-driver/bson/primitive"
     "go.mongodb.org/mongo-driver/mongo"

+ 3 - 3
tools/goctlwt/model/mongo/template/model_custom.tpl

@@ -1,9 +1,9 @@
 package model
 
 {{if .Cache}}import (
-    "github.com/wuntsong-org/go-zero-plus/core/stores/cache"
-    "github.com/wuntsong-org/go-zero-plus/core/stores/monc"
-){{else}}import "github.com/wuntsong-org/go-zero-plus/core/stores/mon"{{end}}
+    "github.com/zeromicro/go-zero/core/stores/cache"
+    "github.com/zeromicro/go-zero/core/stores/monc"
+){{else}}import "github.com/zeromicro/go-zero/core/stores/mon"{{end}}
 
 {{if .Easy}}
 const {{.Type}}CollectionName = "{{.snakeType}}"

+ 10 - 11
tools/goctlwt/model/sql/README.MD

@@ -7,7 +7,7 @@ goctl model 为go-zero下的工具模块中的组件之一,目前支持识别m
 * 通过ddl生成
 
     ```shell script
-    goctl model mysql ddl -src="./*.sql" -dir="./sql/model" -c
+    goctlwt model mysql ddl -src="./*.sql" -dir="./sql/model" -c
     ```
 
     执行上述命令后即可快速生成CURD代码。
@@ -21,7 +21,7 @@ goctl model 为go-zero下的工具模块中的组件之一,目前支持识别m
 * 通过datasource生成
 
     ```shell script
-    goctl model mysql datasource -url="user:password@tcp(127.0.0.1:3306)/database" -table="*"  -dir="./model"
+    goctlwt model mysql datasource -url="user:password@tcp(127.0.0.1:3306)/database" -table="*"  -dir="./model"
     ```
 
 * 生成代码示例
@@ -246,7 +246,7 @@ OPTIONS:
   * ddl
 
 	```shell script
-	goctl model mysql -src={patterns} -dir={dir} -cache
+	goctlwt model mysql -src={patterns} -dir={dir} -cache
 	```
 
 	help
@@ -270,7 +270,7 @@ OPTIONS:
   * datasource
 
 	```shell script
-	goctl model mysql datasource -url={datasource} -table={patterns}  -dir={dir} -cache=true
+	goctlwt model mysql datasource -url={datasource} -table={patterns}  -dir={dir} -cache=true
 	```
 
 	help
@@ -304,26 +304,26 @@ OPTIONS:
   * ddl
   
       ```shell script
-        goctl model -src={patterns} -dir={dir}
+        goctlwt model -src={patterns} -dir={dir}
       ```
 
   * datasource
   
       ```shell script
-        goctl model mysql datasource -url={datasource} -table={patterns}  -dir={dir}
+        goctlwt model mysql datasource -url={datasource} -table={patterns}  -dir={dir}
       ```
 
   or
   * ddl
 
       ```shell script
-        goctl model -src={patterns} -dir={dir}
+        goctlwt model -src={patterns} -dir={dir}
       ```
 
   * datasource
   
       ```shell script
-        goctl model mysql datasource -url={datasource} -table={patterns}  -dir={dir}
+        goctlwt model mysql datasource -url={datasource} -table={patterns}  -dir={dir}
       ```
   
 生成代码仅基本的CURD结构。
@@ -344,7 +344,7 @@ OPTIONS:
   
   理论上是没任何问题,但是我们认为,对于model层的数据操作均是以整个结构体为单位,包括查询,我不建议只查询某部分字段(不反对),否则我们的缓存就没有意义了。
 
-* 为什么不支持`findPageLimit`、`findAll`这种模型代码生成
+* 为什么不支持`findPageLimit`、`findAll`这么模式代码生层
   
   目前,我认为除了基本的CURD外,其他的代码均属于<i>业务型</i>代码,这个我觉得开发人员根据业务需要进行编写更好。
 
@@ -378,5 +378,4 @@ OPTIONS:
 | longtext       | string          | sql.NullString                         |
 | enum           | string          | sql.NullString                         |
 | set            | string          | sql.NullString                         |
-| json           | string          | sql.NullString                         |
-
+| json           | string          | sql.NullString                         |

+ 3 - 3
tools/goctlwt/model/sql/builderx/builder.go

@@ -4,17 +4,17 @@ import (
 	"github.com/wuntsong-org/go-zero-plus/core/stores/builder"
 )
 
-// Deprecated: Use github.com/wuntsong-org/go-zero-plus/core/stores/builder.RawFieldNames instead.
+// Deprecated: Use github.com/zeromicro/go-zero/core/stores/builder.RawFieldNames instead.
 func FieldNames(in any) []string {
 	return builder.RawFieldNames(in)
 }
 
-// Deprecated: Use github.com/wuntsong-org/go-zero-plus/core/stores/builder.RawFieldNames instead.
+// Deprecated: Use github.com/zeromicro/go-zero/core/stores/builder.RawFieldNames instead.
 func RawFieldNames(in any, postgresSql ...bool) []string {
 	return builder.RawFieldNames(in, postgresSql...)
 }
 
-// Deprecated: Use github.com/wuntsong-org/go-zero-plus/core/stores/builderx.PostgreSqlJoin instead.
+// Deprecated: Use github.com/zeromicro/go-zero/core/stores/builderx.PostgreSqlJoin instead.
 func PostgreSqlJoin(elems []string) string {
 	return builder.PostgreSqlJoin(elems)
 }

+ 13 - 7
tools/goctlwt/model/sql/command/command.go

@@ -35,13 +35,15 @@ var (
 	VarStringURL string
 	// VarStringSliceTable describes tables.
 	VarStringSliceTable []string
+	// VarStringTable describes a table of sql.
+	VarStringTable string
 	// VarStringStyle describes the style.
 	VarStringStyle string
 	// VarStringDatabase describes the database.
 	VarStringDatabase string
 	// VarStringSchema describes the schema of postgresql.
 	VarStringSchema string
-	// VarStringHome describes the goctl home.
+	// VarStringHome describes the goctlwt home.
 	VarStringHome string
 	// VarStringRemote describes the remote git repository.
 	VarStringRemote string
@@ -209,14 +211,13 @@ func PostgreSqlDataSource(_ *cobra.Command, _ []string) error {
 		schema = "public"
 	}
 
-	patterns := parseTableList(VarStringSliceTable)
+	pattern := strings.TrimSpace(VarStringTable)
 	cfg, err := config.NewConfig(style)
 	if err != nil {
 		return err
 	}
-	ignoreColumns := mergeColumns(VarStringSliceIgnoreColumns)
 
-	return fromPostgreSqlDataSource(url, patterns, dir, schema, cfg, cache, idea, VarBoolStrict, ignoreColumns)
+	return fromPostgreSqlDataSource(url, pattern, dir, schema, cfg, cache, idea, VarBoolStrict)
 }
 
 type ddlArg struct {
@@ -328,7 +329,7 @@ func fromMysqlDataSource(arg dataSourceArg) error {
 	return generator.StartFromInformationSchema(matchTables, arg.cache, arg.strict)
 }
 
-func fromPostgreSqlDataSource(url string, pattern pattern, dir, schema string, cfg *config.Config, cache, idea, strict bool, ignoreColumns []string) error {
+func fromPostgreSqlDataSource(url, pattern, dir, schema string, cfg *config.Config, cache, idea, strict bool) error {
 	log := console.NewConsole(idea)
 	if len(url) == 0 {
 		log.Error("%v", "expected data source of postgresql, but nothing found")
@@ -349,7 +350,12 @@ func fromPostgreSqlDataSource(url string, pattern pattern, dir, schema string, c
 
 	matchTables := make(map[string]*model.Table)
 	for _, item := range tables {
-		if !pattern.Match(item) {
+		match, err := filepath.Match(pattern, item)
+		if err != nil {
+			return err
+		}
+
+		if !match {
 			continue
 		}
 
@@ -370,7 +376,7 @@ func fromPostgreSqlDataSource(url string, pattern pattern, dir, schema string, c
 		return errors.New("no tables matched")
 	}
 
-	generator, err := gen.NewDefaultGenerator(dir, cfg, gen.WithConsoleOption(log), gen.WithPostgreSql(), gen.WithIgnoreColumns(ignoreColumns))
+	generator, err := gen.NewDefaultGenerator(dir, cfg, gen.WithConsoleOption(log), gen.WithPostgreSql())
 	if err != nil {
 		return err
 	}

+ 2 - 2
tools/goctlwt/model/sql/command/migrationnotes/v1.3.4.go

@@ -15,10 +15,10 @@ func migrateBefore1_3_4(dir, style string) error {
 		return nil
 	}
 
-	fmt.Println(`It seems like that your goctl has just been upgraded to version 1.3.4 or later, which refactored the code of the model module. The original XXXmodel.go has been split into XXXmodel_gen.go (read-only) and XXXmodel.go. You just need to follow these steps to complete the migration:
+	fmt.Println(`It seems like that your goctlwt has just been upgraded to version 1.3.4 or later, which refactored the code of the model module. The original XXXmodel.go has been split into XXXmodel_gen.go (read-only) and XXXmodel.go. You just need to follow these steps to complete the migration:
 1. back up the original XXXmodel.go (make sure the file name is no longer in the current directory)
 2. re-run the generate command (a new XXXmodel.go will be created)
-3. populate XXXmodel.go with the code that is not generated by goctl according to the comments in XXXmodel_gen.go`)
+3. populate XXXmodel.go with the code that is not generated by goctlwt according to the comments in XXXmodel_gen.go`)
 
 	return nil
 }

+ 1 - 1
tools/goctlwt/model/sql/command/migrationnotes/v1.3.4_test.go

@@ -11,7 +11,7 @@ import (
 )
 
 func Test_needShow1_3_4(t *testing.T) {
-	root, err := os.MkdirTemp("", "goctl-model")
+	root, err := os.MkdirTemp("", "goctlwt-model")
 	require.NoError(t, err)
 	defer os.RemoveAll(root)
 

+ 4 - 4
tools/goctlwt/model/sql/gen/keys_test.go

@@ -76,9 +76,9 @@ func TestGenCacheKeys(t *testing.T) {
 				VarExpression:     `cacheGoZeroUserIdPrefix = "cache:goZero:user:id:"`,
 				KeyLeft:           "goZeroUserIdKey",
 				KeyRight:          `fmt.Sprintf("%s%v", cacheGoZeroUserIdPrefix, id)`,
-				DataKeyRight:      `fmt.Sprintf("%s%v", cacheGoZeroUserIdPrefix, data.Id)`,
+				DataKeyRight:      `fmt.Sprintf("%s%v", cacheGoZeroUserIdPrefix, data.ID)`,
 				KeyExpression:     `goZeroUserIdKey := fmt.Sprintf("%s%v", cacheGoZeroUserIdPrefix, id)`,
-				DataKeyExpression: `goZeroUserIdKey := fmt.Sprintf("%s%v", cacheGoZeroUserIdPrefix, data.Id)`,
+				DataKeyExpression: `goZeroUserIdKey := fmt.Sprintf("%s%v", cacheGoZeroUserIdPrefix, data.ID)`,
 				FieldNameJoin:     []string{"id"},
 			})
 		}())
@@ -170,9 +170,9 @@ func TestGenCacheKeys(t *testing.T) {
 				VarExpression:     `cacheUserIdPrefix = "cache:user:id:"`,
 				KeyLeft:           "userIdKey",
 				KeyRight:          `fmt.Sprintf("%s%v", cacheUserIdPrefix, id)`,
-				DataKeyRight:      `fmt.Sprintf("%s%v", cacheUserIdPrefix, data.Id)`,
+				DataKeyRight:      `fmt.Sprintf("%s%v", cacheUserIdPrefix, data.ID)`,
 				KeyExpression:     `userIdKey := fmt.Sprintf("%s%v", cacheUserIdPrefix, id)`,
-				DataKeyExpression: `userIdKey := fmt.Sprintf("%s%v", cacheUserIdPrefix, data.Id)`,
+				DataKeyExpression: `userIdKey := fmt.Sprintf("%s%v", cacheUserIdPrefix, data.ID)`,
 				FieldNameJoin:     []string{"id"},
 			})
 		}())

+ 14 - 11
tools/goctlwt/model/sql/parser/parser.go

@@ -7,12 +7,13 @@ import (
 	"strings"
 
 	"github.com/wuntsong-org/go-zero-plus/core/collection"
+	"github.com/zeromicro/ddl-parser/parser"
+
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/model/sql/converter"
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/model/sql/model"
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/model/sql/util"
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/console"
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/util/stringx"
-	"github.com/zeromicro/ddl-parser/parser"
 )
 
 const timeImport = "time.Time"
@@ -82,9 +83,8 @@ func Parse(filename, database string, strict bool) ([]*Table, error) {
 			primaryColumn    string
 			primaryColumnSet = collection.NewSet()
 			uniqueKeyMap     = make(map[string][]string)
-			// Unused local variable
-			// normalKeyMap     = make(map[string][]string)
-			columns = e.Columns
+			normalKeyMap     = make(map[string][]string)
+			columns          = e.Columns
 		)
 
 		for _, column := range columns {
@@ -127,8 +127,6 @@ func Parse(filename, database string, strict bool) ([]*Table, error) {
 			return nil, fmt.Errorf("%s: unexpected join primary key", prefix)
 		}
 
-		delete(uniqueKeyMap, indexNameGen(primaryColumn, "idx"))
-		delete(uniqueKeyMap, indexNameGen(primaryColumn, "unique"))
 		primaryKey, fieldM, err := convertColumns(columns, primaryColumn, strict)
 		if err != nil {
 			return nil, err
@@ -144,18 +142,23 @@ func Parse(filename, database string, strict bool) ([]*Table, error) {
 			}
 		}
 
-		uniqueIndex := make(map[string][]*Field)
+		var (
+			uniqueIndex = make(map[string][]*Field)
+			normalIndex = make(map[string][]*Field)
+		)
 
 		for indexName, each := range uniqueKeyMap {
 			for _, columnName := range each {
-				// Prevent a crash if there is a unique key constraint with a nil field.
-				if fieldM[columnName] == nil {
-					return nil, fmt.Errorf("table %s: unique key with error column name[%s]", e.Name, columnName)
-				}
 				uniqueIndex[indexName] = append(uniqueIndex[indexName], fieldM[columnName])
 			}
 		}
 
+		for indexName, each := range normalKeyMap {
+			for _, columnName := range each {
+				normalIndex[indexName] = append(normalIndex[indexName], fieldM[columnName])
+			}
+		}
+
 		checkDuplicateUniqueIndex(uniqueIndex, e.Name)
 
 		list = append(list, &Table{

+ 1 - 1
tools/goctlwt/model/sql/template/tpl/err.tpl

@@ -1,5 +1,5 @@
 package {{.pkg}}
 
-import "github.com/wuntsong-org/go-zero-plus/core/stores/sqlx"
+import "github.com/zeromicro/go-zero/core/stores/sqlx"
 
 var ErrNotFound = sqlx.ErrNotFound

+ 1 - 1
tools/goctlwt/model/sql/template/tpl/find-one.tpl

@@ -18,7 +18,7 @@ func (m *default{{.upperStartCamelObject}}Model) FindOne(ctx context.Context, {{
 	switch err {
 	case nil:
 		return &resp, nil
-	case sqlx.ErrNotFound:
+	case sqlc.ErrNotFound:
 		return nil, ErrNotFound
 	default:
 		return nil, err

+ 4 - 4
tools/goctlwt/model/sql/template/tpl/import-no-cache.tpl

@@ -6,8 +6,8 @@ import (
 	{{if .time}}"time"{{end}}
 
     {{if .containsPQ}}"github.com/lib/pq"{{end}}
-	"github.com/wuntsong-org/go-zero-plus/core/stores/builder"
-	"github.com/wuntsong-org/go-zero-plus/core/stores/sqlc"
-	"github.com/wuntsong-org/go-zero-plus/core/stores/sqlx"
-	"github.com/wuntsong-org/go-zero-plus/core/stringx"
+	"github.com/zeromicro/go-zero/core/stores/builder"
+	"github.com/zeromicro/go-zero/core/stores/sqlc"
+	"github.com/zeromicro/go-zero/core/stores/sqlx"
+	"github.com/zeromicro/go-zero/core/stringx"
 )

+ 5 - 5
tools/goctlwt/model/sql/template/tpl/import.tpl

@@ -6,9 +6,9 @@ import (
 	{{if .time}}"time"{{end}}
 
 	{{if .containsPQ}}"github.com/lib/pq"{{end}}
-	"github.com/wuntsong-org/go-zero-plus/core/stores/builder"
-	"github.com/wuntsong-org/go-zero-plus/core/stores/cache"
-	"github.com/wuntsong-org/go-zero-plus/core/stores/sqlc"
-	"github.com/wuntsong-org/go-zero-plus/core/stores/sqlx"
-	"github.com/wuntsong-org/go-zero-plus/core/stringx"
+	"github.com/zeromicro/go-zero/core/stores/builder"
+	"github.com/zeromicro/go-zero/core/stores/cache"
+	"github.com/zeromicro/go-zero/core/stores/sqlc"
+	"github.com/zeromicro/go-zero/core/stores/sqlx"
+	"github.com/zeromicro/go-zero/core/stringx"
 )

+ 6 - 0
tools/goctlwt/model/sql/template/tpl/model-new.tpl

@@ -5,3 +5,9 @@ func new{{.upperStartCamelObject}}Model(conn sqlx.SqlConn{{if .withCache}}, c ca
 	}
 }
 
+func (m *default{{.upperStartCamelObject}}Model) withSession(session sqlx.Session) *default{{.upperStartCamelObject}}Model {
+	return &default{{.upperStartCamelObject}}Model{
+		{{if .withCache}}CachedConn:m.CachedConn.WithSession(session){{else}}conn:sqlx.NewSqlConnFromSession(session){{end}},
+		table:      {{.table}},
+	}
+}

+ 3 - 11
tools/goctlwt/model/sql/template/tpl/model.tpl

@@ -1,12 +1,12 @@
 package {{.pkg}}
 {{if .withCache}}
 import (
-	"github.com/wuntsong-org/go-zero-plus/core/stores/cache"
-	"github.com/wuntsong-org/go-zero-plus/core/stores/sqlx"
+	"github.com/zeromicro/go-zero/core/stores/cache"
+	"github.com/zeromicro/go-zero/core/stores/sqlx"
 )
 {{else}}
 
-import "github.com/wuntsong-org/go-zero-plus/core/stores/sqlx"
+import "github.com/zeromicro/go-zero/core/stores/sqlx"
 {{end}}
 var _ {{.upperStartCamelObject}}Model = (*custom{{.upperStartCamelObject}}Model)(nil)
 
@@ -15,7 +15,6 @@ type (
 	// and implement the added methods in custom{{.upperStartCamelObject}}Model.
 	{{.upperStartCamelObject}}Model interface {
 		{{.lowerStartCamelObject}}Model
-		{{if not .withCache}}withSession(session sqlx.Session) {{.upperStartCamelObject}}Model{{end}}
 	}
 
 	custom{{.upperStartCamelObject}}Model struct {
@@ -29,10 +28,3 @@ func New{{.upperStartCamelObject}}Model(conn sqlx.SqlConn{{if .withCache}}, c ca
 		default{{.upperStartCamelObject}}Model: new{{.upperStartCamelObject}}Model(conn{{if .withCache}}, c, opts...{{end}}),
 	}
 }
-
-{{if not .withCache}}
-func (m *custom{{.upperStartCamelObject}}Model) withSession(session sqlx.Session) {{.upperStartCamelObject}}Model {
-    return New{{.upperStartCamelObject}}Model(sqlx.NewSqlConnFromSession(session))
-}
-{{end}}
-

+ 14 - 8
tools/goctlwt/model/sql/test/model/model_test.go

@@ -43,7 +43,7 @@ func TestStudentModel(t *testing.T) {
 		Valid: true,
 	}
 
-	err := mockStudent(t, func(mock sqlmock.Sqlmock) {
+	err := mockStudent(func(mock sqlmock.Sqlmock) {
 		mock.ExpectExec(fmt.Sprintf("insert into %s", testTable)).
 			WithArgs(data.Class, data.Name, data.Age, data.Score).
 			WillReturnResult(sqlmock.NewResult(testInsertId, testRowsAffected))
@@ -61,7 +61,7 @@ func TestStudentModel(t *testing.T) {
 	})
 	assert.Nil(t, err)
 
-	err = mockStudent(t, func(mock sqlmock.Sqlmock) {
+	err = mockStudent(func(mock sqlmock.Sqlmock) {
 		mock.ExpectQuery(fmt.Sprintf("select (.+) from %s", testTable)).
 			WithArgs(testInsertId).
 			WillReturnRows(sqlmock.NewRows([]string{"id", "class", "name", "age", "score", "create_time", "update_time"}).AddRow(testInsertId, data.Class, data.Name, data.Age, data.Score, testTimeValue, testTimeValue))
@@ -79,7 +79,7 @@ func TestStudentModel(t *testing.T) {
 	})
 	assert.Nil(t, err)
 
-	err = mockStudent(t, func(mock sqlmock.Sqlmock) {
+	err = mockStudent(func(mock sqlmock.Sqlmock) {
 		mock.ExpectExec(fmt.Sprintf("update %s", testTable)).WithArgs(data.Class, testUpdateName, data.Age, data.Score, testInsertId).WillReturnResult(sqlmock.NewResult(testInsertId, testRowsAffected))
 	}, func(m StudentModel, redis *redis.Redis) {
 		data.Name = testUpdateName
@@ -93,7 +93,7 @@ func TestStudentModel(t *testing.T) {
 	assert.Nil(t, err)
 
 	data.Name = testUpdateName
-	err = mockStudent(t, func(mock sqlmock.Sqlmock) {
+	err = mockStudent(func(mock sqlmock.Sqlmock) {
 		mock.ExpectQuery(fmt.Sprintf("select (.+) from %s ", testTable)).
 			WithArgs(testInsertId).
 			WillReturnRows(sqlmock.NewRows([]string{"id", "class", "name", "age", "score", "create_time", "update_time"}).AddRow(testInsertId, data.Class, data.Name, data.Age, data.Score, testTimeValue, testTimeValue))
@@ -111,7 +111,7 @@ func TestStudentModel(t *testing.T) {
 	})
 	assert.Nil(t, err)
 
-	err = mockStudent(t, func(mock sqlmock.Sqlmock) {
+	err = mockStudent(func(mock sqlmock.Sqlmock) {
 		mock.ExpectQuery(fmt.Sprintf("select (.+) from %s ", testTable)).
 			WithArgs(class, testUpdateName).
 			WillReturnRows(sqlmock.NewRows([]string{"id", "class", "name", "age", "score", "create_time", "update_time"}).AddRow(testInsertId, data.Class, data.Name, data.Age, data.Score, testTimeValue, testTimeValue))
@@ -126,7 +126,7 @@ func TestStudentModel(t *testing.T) {
 	})
 	assert.Nil(t, err)
 
-	err = mockStudent(t, func(mock sqlmock.Sqlmock) {
+	err = mockStudent(func(mock sqlmock.Sqlmock) {
 		mock.ExpectExec(fmt.Sprintf("delete from %s where `id` = ?", testTable)).WithArgs(testInsertId).WillReturnResult(sqlmock.NewResult(testInsertId, testRowsAffected))
 	}, func(m StudentModel, redis *redis.Redis) {
 		err = m.Delete(testInsertId, class, testUpdateName)
@@ -228,7 +228,7 @@ func TestUserModel(t *testing.T) {
 }
 
 // with cache
-func mockStudent(t *testing.T, mockFn func(mock sqlmock.Sqlmock), fn func(m StudentModel, r *redis.Redis)) error {
+func mockStudent(mockFn func(mock sqlmock.Sqlmock), fn func(m StudentModel, r *redis.Redis)) error {
 	db, mock, err := sqlmock.New()
 	if err != nil {
 		return err
@@ -241,7 +241,13 @@ func mockStudent(t *testing.T, mockFn func(mock sqlmock.Sqlmock), fn func(m Stud
 	mock.ExpectCommit()
 
 	conn := mocksql.NewMockConn(db)
-	r := redistest.CreateRedis(t)
+	r, clean, err := redistest.CreateRedis()
+	if err != nil {
+		return err
+	}
+
+	defer clean()
+
 	m := NewStudentModel(conn, cache.CacheConf{
 		{
 			RedisConf: redis.RedisConf{

+ 2 - 2
tools/goctlwt/model/sql/test/orm.go

@@ -128,7 +128,7 @@ func unmarshalRow(v any, scanner rowsScanner, strict bool) error {
 	}
 
 	rv := reflect.ValueOf(v)
-	if err := mapping.ValidatePtr(rv); err != nil {
+	if err := mapping.ValidatePtr(&rv); err != nil {
 		return err
 	}
 
@@ -163,7 +163,7 @@ func unmarshalRow(v any, scanner rowsScanner, strict bool) error {
 
 func unmarshalRows(v any, scanner rowsScanner, strict bool) error {
 	rv := reflect.ValueOf(v)
-	if err := mapping.ValidatePtr(rv); err != nil {
+	if err := mapping.ValidatePtr(&rv); err != nil {
 		return err
 	}
 

+ 3 - 12
tools/goctlwt/pkg/env/env.go

@@ -7,7 +7,6 @@ import (
 	"path/filepath"
 	"runtime"
 	"strings"
-	"testing"
 
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/internal/version"
 	sortedmap "github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/collection"
@@ -36,7 +35,7 @@ const (
 	ExperimentalOff = "off"
 )
 
-// init initializes the goctl environment variables, the environment variables of the function are set in order,
+// init initializes the goctlwt environment variables, the environment variables of the function are set in order,
 // please do not change the logic order of the code.
 func init() {
 	defaultGoctlHome, err := pathx.GetDefaultGoctlHome()
@@ -60,7 +59,7 @@ func init() {
 		if value := existsEnv.GetStringOr(GoctlCache, ""); value != "" {
 			goctlEnv.SetKV(GoctlCache, value)
 		}
-		experimental := existsEnv.GetOr(GoctlExperimental, ExperimentalOn)
+		experimental := existsEnv.GetOr(GoctlExperimental, ExperimentalOff)
 		goctlEnv.SetKV(GoctlExperimental, experimental)
 	}
 
@@ -77,7 +76,7 @@ func init() {
 	}
 
 	if !goctlEnv.HasKey(GoctlExperimental) {
-		goctlEnv.SetKV(GoctlExperimental, ExperimentalOn)
+		goctlEnv.SetKV(GoctlExperimental, ExperimentalOff)
 	}
 
 	goctlEnv.SetKV(GoctlVersion, version.BuildVersion)
@@ -112,14 +111,6 @@ func Get(key string) string {
 	return GetOr(key, "")
 }
 
-// Set sets the environment variable for testing
-func Set(t *testing.T, key, value string) {
-	goctlEnv.SetKV(key, value)
-	t.Cleanup(func() {
-		goctlEnv.Remove(key)
-	})
-}
-
 func GetOr(key, def string) string {
 	return goctlEnv.GetStringOr(key, def)
 }

+ 1 - 1
tools/goctlwt/pkg/golang/path.go

@@ -19,7 +19,7 @@ func GetParentPackage(dir string) (string, error) {
 		return "", err
 	}
 
-	// fix https://github.com/wuntsong-org/go-zero-plus/issues/1058
+	// fix https://github.com/zeromicro/go-zero/issues/1058
 	wd := projectCtx.WorkDir
 	d := projectCtx.Dir
 	same, err := pathx.SameFile(wd, d)

+ 0 - 31
tools/goctlwt/pkg/parser/api/importstack/importstack.go

@@ -1,31 +0,0 @@
-package importstack
-
-import "errors"
-
-// ErrImportCycleNotAllowed defines an error for circular importing
-var ErrImportCycleNotAllowed = errors.New("import cycle not allowed")
-
-// ImportStack a stack of import paths
-type ImportStack []string
-
-func New() *ImportStack {
-	return &ImportStack{}
-}
-
-func (s *ImportStack) Push(p string) error {
-	for _, x := range *s {
-		if x == p {
-			return ErrImportCycleNotAllowed
-		}
-	}
-	*s = append(*s, p)
-	return nil
-}
-
-func (s *ImportStack) Pop() {
-	*s = (*s)[0 : len(*s)-1]
-}
-
-func (s *ImportStack) List() []string {
-	return *s
-}

+ 9 - 45
tools/goctlwt/pkg/parser/api/parser/analyzer.go

@@ -2,13 +2,10 @@ package parser
 
 import (
 	"fmt"
-	"sort"
 	"strings"
 
-	"github.com/wuntsong-org/go-zero-plus/core/lang"
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/api/spec"
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/parser/api/ast"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/parser/api/importstack"
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/parser/api/placeholder"
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/parser/api/token"
 )
@@ -21,14 +18,13 @@ type Analyzer struct {
 
 func (a *Analyzer) astTypeToSpec(in ast.DataType) (spec.Type, error) {
 	isLiteralType := func(dt ast.DataType) bool {
-		if _, ok := dt.(*ast.BaseDataType); ok {
+		_, ok := dt.(*ast.BaseDataType)
+		if ok {
 			return true
 		}
-
-		_, ok := dt.(*ast.AnyDataType)
+		_, ok = dt.(*ast.AnyDataType)
 		return ok
 	}
-
 	switch v := (in).(type) {
 	case *ast.BaseDataType:
 		raw := v.RawText()
@@ -37,7 +33,6 @@ func (a *Analyzer) astTypeToSpec(in ast.DataType) (spec.Type, error) {
 				RawName: raw,
 			}, nil
 		}
-
 		return spec.DefineStruct{RawName: raw}, nil
 	case *ast.AnyDataType:
 		return nil, ast.SyntaxError(v.Pos(), "unsupported any type")
@@ -52,12 +47,10 @@ func (a *Analyzer) astTypeToSpec(in ast.DataType) (spec.Type, error) {
 		if !v.Key.CanEqual() {
 			return nil, ast.SyntaxError(v.Pos(), "map key <%T> must be equal data type", v)
 		}
-
 		value, err := a.astTypeToSpec(v.Value)
 		if err != nil {
 			return nil, err
 		}
-
 		return spec.MapType{
 			RawName: v.RawText(),
 			Key:     v.RawText(),
@@ -73,7 +66,6 @@ func (a *Analyzer) astTypeToSpec(in ast.DataType) (spec.Type, error) {
 		if err != nil {
 			return nil, err
 		}
-
 		return spec.PointerType{
 			RawName: v.RawText(),
 			Type:    value,
@@ -82,12 +74,10 @@ func (a *Analyzer) astTypeToSpec(in ast.DataType) (spec.Type, error) {
 		if v.Length.Token.Type == token.ELLIPSIS {
 			return nil, ast.SyntaxError(v.Pos(), "Array: unsupported dynamic length")
 		}
-
 		value, err := a.astTypeToSpec(v.DataType)
 		if err != nil {
 			return nil, err
 		}
-
 		return spec.ArrayType{
 			RawName: v.RawText(),
 			Value:   value,
@@ -97,7 +87,6 @@ func (a *Analyzer) astTypeToSpec(in ast.DataType) (spec.Type, error) {
 		if err != nil {
 			return nil, err
 		}
-
 		return spec.ArrayType{
 			RawName: v.RawText(),
 			Value:   value,
@@ -112,27 +101,7 @@ func (a *Analyzer) convert2Spec() error {
 		return err
 	}
 
-	if err := a.fillService(); err != nil {
-		return err
-	}
-
-	sort.SliceStable(a.spec.Types, func(i, j int) bool {
-		return a.spec.Types[i].Name() < a.spec.Types[j].Name()
-	})
-
-	groups := make([]spec.Group, 0, len(a.spec.Service.Groups))
-	for _, v := range a.spec.Service.Groups {
-		sort.SliceStable(v.Routes, func(i, j int) bool {
-			return v.Routes[i].Path < v.Routes[j].Path
-		})
-		groups = append(groups, v)
-	}
-	sort.SliceStable(groups, func(i, j int) bool {
-		return groups[i].Annotation.Properties["group"] < groups[j].Annotation.Properties["group"]
-	})
-	a.spec.Service.Groups = groups
-
-	return nil
+	return a.fillService()
 }
 
 func (a *Analyzer) convertAtDoc(atDoc ast.AtDocStmt) spec.AtDoc {
@@ -177,7 +146,6 @@ func (a *Analyzer) fieldToMember(field *ast.ElemExpr) (spec.Member, error) {
 	if field.Tag != nil {
 		m.Tag = field.Tag.Token.Text
 	}
-
 	return m, nil
 }
 
@@ -274,7 +242,8 @@ func (a *Analyzer) fillTypes() error {
 	for _, item := range a.api.TypeStmt {
 		switch v := (item).(type) {
 		case *ast.TypeLiteralStmt:
-			if err := a.fillTypeExpr(v.Expr); err != nil {
+			err := a.fillTypeExpr(v.Expr)
+			if err != nil {
 				return err
 			}
 		case *ast.TypeGroupStmt:
@@ -392,14 +361,9 @@ func Parse(filename string, src interface{}) (*spec.ApiSpec, error) {
 		return nil, err
 	}
 
-	is := importstack.New()
-	err := is.Push(ast.Filename)
-	if err != nil {
-		return nil, err
-	}
-
-	importSet := map[string]lang.PlaceholderType{}
-	api, err := convert2API(ast, importSet, is)
+	var importManager = make(map[string]placeholder.Type)
+	importManager[ast.Filename] = placeholder.PlaceHolder
+	api, err := convert2API(ast, importManager)
 	if err != nil {
 		return nil, err
 	}

+ 18 - 46
tools/goctlwt/pkg/parser/api/parser/api.go

@@ -5,9 +5,7 @@ import (
 	"path/filepath"
 	"strings"
 
-	"github.com/wuntsong-org/go-zero-plus/core/lang"
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/parser/api/ast"
-	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/parser/api/importstack"
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/parser/api/placeholder"
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/pkg/parser/api/token"
 )
@@ -20,55 +18,31 @@ type API struct {
 	importStmt    []ast.ImportStmt // ImportStmt block does not participate in code generation.
 	TypeStmt      []ast.TypeStmt
 	ServiceStmts  []*ast.ServiceStmt
-	importManager *importstack.ImportStack
-	importSet     map[string]lang.PlaceholderType
+	importManager map[string]placeholder.Type
 }
 
-func convert2API(a *ast.AST, importSet map[string]lang.PlaceholderType, is *importstack.ImportStack) (*API, error) {
+func convert2API(a *ast.AST, importManager map[string]placeholder.Type) (*API, error) {
 	var api = new(API)
-	api.importManager = is
-	api.importSet = make(map[string]lang.PlaceholderType)
+	api.importManager = make(map[string]placeholder.Type)
 	api.Filename = a.Filename
-	for k, v := range importSet {
-		api.importSet[k] = v
+	for k, v := range importManager {
+		api.importManager[k] = v
 	}
 	one := a.Stmts[0]
 	syntax, ok := one.(*ast.SyntaxStmt)
 	if !ok {
-		syntax = &ast.SyntaxStmt{
-			Syntax: ast.NewTokenNode(token.Token{
-				Type: token.IDENT,
-				Text: token.Syntax,
-			}),
-			Assign: ast.NewTokenNode(token.Token{
-				Type: token.ASSIGN,
-				Text: "=",
-			}),
-			Value: ast.NewTokenNode(token.Token{
-				Type: token.STRING,
-				Text: `"v1"`,
-			}),
-		}
+		return nil, ast.SyntaxError(one.Pos(), "expected syntax statement, got <%T>", one)
 	}
-
 	api.Syntax = syntax
-	var hasSyntax, hasInfo bool
-	for i := 0; i < len(a.Stmts); i++ {
+
+	for i := 1; i < len(a.Stmts); i++ {
 		one := a.Stmts[i]
 		switch val := one.(type) {
 		case *ast.SyntaxStmt:
-			if hasSyntax {
-				return nil, ast.DuplicateStmtError(val.Pos(), "duplicate syntax statement")
-			} else {
-				hasSyntax = true
-			}
+			return nil, ast.DuplicateStmtError(val.Pos(), "duplicate syntax statement")
 		case *ast.InfoStmt:
 			if api.info != nil {
-				if hasInfo {
-					return nil, ast.DuplicateStmtError(val.Pos(), "duplicate info statement")
-				}
-			} else {
-				hasInfo = true
+				return nil, ast.DuplicateStmtError(val.Pos(), "duplicate info statement")
 			}
 			api.info = val
 		case ast.ImportStmt:
@@ -234,6 +208,9 @@ func (api *API) getAtServerValue(atServer *ast.AtServerStmt, key string) string
 }
 
 func (api *API) mergeAPI(in *API) error {
+	for k, v := range in.importManager {
+		api.importManager[k] = v
+	}
 	if api.Syntax.Value.Format() != in.Syntax.Value.Format() {
 		return ast.SyntaxError(in.Syntax.Value.Pos(),
 			"multiple syntax value expression, expected <%s>, got <%s>",
@@ -270,15 +247,11 @@ func (api *API) parseImportedAPI(imports []ast.ImportStmt) ([]*API, error) {
 			impPath = filepath.Join(dir, impPath)
 		}
 		// import cycle check
-		if err := api.importManager.Push(impPath); err != nil {
-			return nil, ast.SyntaxError(tok.Position, err.Error())
-		}
-
-		if _, ok := api.importSet[impPath]; ok {
-			api.importManager.Pop()
-			continue
+		if _, ok := api.importManager[impPath]; ok {
+			return nil, ast.SyntaxError(tok.Position, "import circle not allowed")
+		} else {
+			api.importManager[impPath] = placeholder.PlaceHolder
 		}
-		api.importSet[impPath] = lang.Placeholder
 
 		p := New(impPath, "")
 		ast := p.Parse()
@@ -286,7 +259,7 @@ func (api *API) parseImportedAPI(imports []ast.ImportStmt) ([]*API, error) {
 			return nil, err
 		}
 
-		nestedApi, err := convert2API(ast, api.importSet, api.importManager)
+		nestedApi, err := convert2API(ast, api.importManager)
 		if err != nil {
 			return nil, err
 		}
@@ -295,7 +268,6 @@ func (api *API) parseImportedAPI(imports []ast.ImportStmt) ([]*API, error) {
 			return nil, err
 		}
 
-		api.importManager.Pop()
 		list = append(list, nestedApi)
 
 		if err != nil {

+ 4 - 0
tools/goctlwt/pkg/parser/api/parser/testdata/invalid.api

@@ -1,3 +1,7 @@
+// test case: expected syntax statement
+info ()
+
+-----
 // test case: duplicate syntax statement
 syntax = "v1"
 syntax = "v1"

+ 8 - 12
tools/goctlwt/pkg/parser/api/scanner/scanner.go

@@ -26,6 +26,7 @@ const (
 	stringOpen
 	stringClose
 	// string mode end
+
 )
 
 var missingInput = errors.New("missing input")
@@ -267,7 +268,6 @@ func (s *Scanner) scanNanosecond(bgPos int) token.Token {
 		return s.illegalToken()
 	}
 	s.readRune()
-
 	return token.Token{
 		Type:     token.DURATION,
 		Text:     string(s.data[bgPos:s.position]),
@@ -485,7 +485,6 @@ func (s *Scanner) scanLineComment() token.Token {
 	for s.ch != '\n' && s.ch != 0 {
 		s.readRune()
 	}
-
 	return token.Token{
 		Type:     token.COMMENT,
 		Text:     string(s.data[position:s.position]),
@@ -547,7 +546,6 @@ func (s *Scanner) assertExpected(actual token.Type, expected ...token.Type) erro
 		strings.Join(expects, " | "),
 		actual.String(),
 	))
-
 	return errors.New(text)
 }
 
@@ -562,7 +560,6 @@ func (s *Scanner) assertExpectedString(actual string, expected ...string) error
 		strings.Join(expects, " | "),
 		actual,
 	))
-
 	return errors.New(text)
 }
 
@@ -650,22 +647,21 @@ func NewScanner(filename string, src interface{}) (*Scanner, error) {
 }
 
 func readData(filename string, src interface{}) ([]byte, error) {
-	if strings.HasSuffix(filename, ".api") {
-		data, err := os.ReadFile(filename)
-		if err != nil {
-			return nil, err
-		}
+	data, err := os.ReadFile(filename)
+	if err == nil {
 		return data, nil
 	}
 
 	switch v := src.(type) {
 	case []byte:
-		return v, nil
+		data = append(data, v...)
 	case *bytes.Buffer:
-		return v.Bytes(), nil
+		data = v.Bytes()
 	case string:
-		return []byte(v), nil
+		data = []byte(v)
 	default:
 		return nil, fmt.Errorf("unsupported type: %T", src)
 	}
+
+	return data, nil
 }

+ 1 - 1
tools/goctlwt/plugin/plugin.go

@@ -40,7 +40,7 @@ var (
 	VarStringStyle string
 )
 
-// PluginCommand is the entry of goctl api plugin
+// PluginCommand is the entry of goctlwt api plugin
 func PluginCommand(_ *cobra.Command, _ []string) error {
 	ex, err := os.Executable()
 	if err != nil {

+ 1 - 1
tools/goctlwt/quickstart/idl/apilogic.tpl

@@ -3,7 +3,7 @@ package logic
 import (
 	"context"
 
-	"github.com/wuntsong-org/go-zero-plus/core/logx"
+	"github.com/zeromicro/go-zero/core/logx"
 
 	"{{.svcPkg}}"
 	"{{.typesPkg}}"{{if .callRPC}}

+ 1 - 1
tools/goctlwt/quickstart/idl/svc.tpl

@@ -2,7 +2,7 @@ package svc
 
 import (
 	"{{.configPkg}}"{{if .callRPC}}
-	"github.com/wuntsong-org/go-zero-plus/zrpc"
+	"github.com/zeromicro/go-zero/zrpc"
 	"{{.rpcClientPkg}}"{{end}}
 )
 

+ 1 - 1
tools/goctlwt/quickstart/micro.go

@@ -52,7 +52,7 @@ func newMicroService() micro {
 func (m micro) mustStartRPCProject() {
 	logx.Must(initRPCProto())
 	log.Debug(">> Generating quickstart zRPC project...")
-	arg := "goctl rpc protoc " + protoName + " --go_out=. --go-grpc_out=. --zrpc_out=. --verbose"
+	arg := "goctlwt rpc protoc " + protoName + " --go_out=. --go-grpc_out=. --zrpc_out=. --verbose"
 	execCommand(zrpcWorkDir, arg)
 	etcFile := filepath.Join(zrpcWorkDir, "etc", "greet.yaml")
 	logx.Must(os.WriteFile(etcFile, []byte(rpcEtcContent), 0o666))

+ 9 - 9
tools/goctlwt/rpc/README.md

@@ -19,7 +19,7 @@ Goctl Rpc是`goctl`脚手架下的一个rpc服务代码生成模块,支持prot
   如生成greet rpc服务:
 
   ```Bash
-  goctl rpc new greet
+  goctlwt rpc new greet
   ```
 
   执行后代码结构如下:
@@ -51,7 +51,7 @@ Goctl Rpc是`goctl`脚手架下的一个rpc服务代码生成模块,支持prot
 * 生成proto模板
 
 ```Bash
-$ goctl rpc template -o=user.proto
+$ goctlwt rpc template -o=user.proto
 ```
   
 ```proto
@@ -77,7 +77,7 @@ service User {
 * 生成rpc服务代码
 
 ```bash
-$ goctl rpc protoc  user.proto --go_out=. --go-grpc_out=. --zrpc_out=.
+$ goctlwt rpc protoc  user.proto --go_out=. --go-grpc_out=. --zrpc_out=.
 ```
 
 
@@ -86,23 +86,23 @@ $ goctl rpc protoc  user.proto --go_out=. --go-grpc_out=. --zrpc_out=.
 ### rpc 服务生成用法
 
 ```Bash
-$ goctl rpc protoc -h
+$ goctlwt rpc protoc -h
 Generate grpc code
 
 Usage:
-  goctl rpc protoc [flags]
+  goctlwt rpc protoc [flags]
 
 Examples:
-goctl rpc protoc xx.proto --go_out=./pb --go-grpc_out=./pb --zrpc_out=.
+goctlwt rpc protoc xx.proto --go_out=./pb --go-grpc_out=./pb --zrpc_out=.
 
 Flags:
       --branch string     The branch of the remote repo, it does work with --remote
   -h, --help              help for protoc
-      --home string       The goctl home path of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
+      --home string       The goctlwt home path of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
   -m, --multiple          Generated in multiple rpc service mode
       --remote string     The remote git repo of the template, --home and --remote cannot be set at the same time, if they are, --remote has higher priority
                           	The git repo directory must be consistent with the https://github.com/wuntsong-org/go-zero-plus-template directory structure
-      --style string      The file naming format, see [https://github.com/wuntsong-org/go-zero-plus/tree/master/tools/goctl/config/readme.md] (default "gozero")
+      --style string      The file naming format, see [https://github.com/wuntsong-org/go-zero-plus/tree/master/tools/goctlwt/config/readme.md] (default "gozero")
   -v, --verbose           Enable log output
       --zrpc_out string   The zrpc output directory
 ```
@@ -127,7 +127,7 @@ Flags:
 
 
 ## rpc 服务生成 example
-详情见 [example/rpc](https://github.com/wuntsong-org/go-zero-plus/tree/master/tools/goctl/example)
+详情见 [example/rpc](https://github.com/zeromicro/go-zero/tree/master/tools/goctl/example)
 
 ## --multiple 为 true 和 false 的目录区别
 源 proto 文件

+ 2 - 2
tools/goctlwt/rpc/cli/cli.go

@@ -16,7 +16,7 @@ import (
 var (
 	// VarStringOutput describes the output.
 	VarStringOutput string
-	// VarStringHome describes the goctl home.
+	// VarStringHome describes the goctlwt home.
 	VarStringHome string
 	// VarStringRemote describes the remote git repository.
 	VarStringRemote string
@@ -109,7 +109,7 @@ func RPCNew(_ *cobra.Command, args []string) error {
 // RPCTemplate is the entry for generate rpc template
 func RPCTemplate(latest bool) error {
 	if !latest {
-		console.Warning("deprecated: goctl rpc template -o is deprecated and will be removed in the future, use goctl rpc -o instead")
+		console.Warning("deprecated: goctlwt rpc template -o is deprecated and will be removed in the future, use goctlwt rpc -o instead")
 	}
 	protoFile := VarStringOutput
 	home := VarStringHome

+ 1 - 1
tools/goctlwt/rpc/cli/zrpc.go

@@ -19,7 +19,7 @@ var (
 )
 
 // ZRPC generates grpc code directly by protoc and generates
-// zrpc code by goctl.
+// zrpc code by goctlwt.
 func ZRPC(_ *cobra.Command, args []string) error {
 	protocArgs := wrapProtocCmd("protoc", args)
 	pwd, err := os.Getwd()

+ 1 - 1
tools/goctlwt/rpc/generator/call.tpl

@@ -8,7 +8,7 @@ import (
 	{{.pbPackage}}
 	{{if ne .pbPackage .protoGoPackage}}{{.protoGoPackage}}{{end}}
 
-	"github.com/wuntsong-org/go-zero-plus/zrpc"
+	"github.com/zeromicro/go-zero/zrpc"
 	"google.golang.org/grpc"
 )
 

+ 1 - 1
tools/goctlwt/rpc/generator/config.tpl

@@ -1,6 +1,6 @@
 package config
 
-import "github.com/wuntsong-org/go-zero-plus/zrpc"
+import "github.com/zeromicro/go-zero/zrpc"
 
 type Config struct {
 	zrpc.RpcServerConf

+ 1 - 1
tools/goctlwt/rpc/generator/genconfig.go

@@ -17,7 +17,7 @@ var configTemplate string
 // GenConfig generates the configuration structure definition file of the rpc service,
 // which contains the zrpc.RpcServerConf configuration item by default.
 // You can specify the naming style of the target file name through config.Config. For details,
-// see https://github.com/wuntsong-org/go-zero-plus/tree/master/tools/goctl/config/config.go
+// see https://github.com/zeromicro/go-zero/tree/master/tools/goctl/config/config.go
 func (g *Generator) GenConfig(ctx DirContext, _ parser.Proto, cfg *conf.Config) error {
 	dir := ctx.GetConfig()
 	configFilename, err := format.FileNamingFormat(cfg.NamingFormat, "config")

+ 6 - 10
tools/goctlwt/rpc/generator/genpb.go

@@ -11,7 +11,7 @@ import (
 )
 
 // GenPb generates the pb.go file, which is a layer of packaging for protoc to generate gprc,
-// but the commands and flags in protoc are not completely joined in goctl. At present, proto_path(-I) is introduced
+// but the commands and flags in protoc are not completely joined in goctlwt. At present, proto_path(-I) is introduced
 func (g *Generator) GenPb(ctx DirContext, c *ZRpcContext) error {
 	return g.genPbDirect(ctx, c)
 }
@@ -31,14 +31,14 @@ func (g *Generator) genPbDirect(ctx DirContext, c *ZRpcContext) error {
 }
 
 func (g *Generator) setPbDir(ctx DirContext, c *ZRpcContext) error {
-	pbDir, err := findPbFile(c.GoOutput, c.Src, false)
+	pbDir, err := findPbFile(c.GoOutput, false)
 	if err != nil {
 		return err
 	}
 	if len(pbDir) == 0 {
 		return fmt.Errorf("pg.go is not found under %q", c.GoOutput)
 	}
-	grpcDir, err := findPbFile(c.GrpcOutput, c.Src, true)
+	grpcDir, err := findPbFile(c.GrpcOutput, true)
 	if err != nil {
 		return err
 	}
@@ -62,11 +62,7 @@ const (
 	grpcSuffix = "_grpc.pb.go"
 )
 
-func findPbFile(current string, src string, grpc bool) (string, error) {
-	protoName := strings.TrimSuffix(filepath.Base(src), filepath.Ext(src))
-	pbFile := protoName + "." + pbSuffix
-	grpcFile := protoName + grpcSuffix
-
+func findPbFile(current string, grpc bool) (string, error) {
 	fileSystem := os.DirFS(current)
 	var ret string
 	err := fs.WalkDir(fileSystem, ".", func(path string, d fs.DirEntry, err error) error {
@@ -75,11 +71,11 @@ func findPbFile(current string, src string, grpc bool) (string, error) {
 		}
 		if strings.HasSuffix(path, pbSuffix) {
 			if grpc {
-				if strings.HasSuffix(path, grpcFile) {
+				if strings.HasSuffix(path, grpcSuffix) {
 					ret = path
 					return os.ErrExist
 				}
-			} else if strings.HasSuffix(path, pbFile) {
+			} else if !strings.HasSuffix(path, grpcSuffix) {
 				ret = path
 				return os.ErrExist
 			}

+ 10 - 10
tools/goctlwt/rpc/generator/genpb_test.go

@@ -46,12 +46,12 @@ service Greeter {
 			t.Log(err)
 			return
 		}
-		pbDir, err := findPbFile(output, protoFile, false)
+		pbDir, err := findPbFile(output, false)
 		assert.Nil(t, err)
 		pbGo := filepath.Join(pbDir, "greet.pb.go")
 		assert.True(t, pathx.FileExists(pbGo))
 
-		grpcDir, err := findPbFile(output, protoFile, true)
+		grpcDir, err := findPbFile(output, true)
 		assert.Nil(t, err)
 		grpcGo := filepath.Join(grpcDir, "greet_grpc.pb.go")
 		assert.True(t, pathx.FileExists(grpcGo))
@@ -76,12 +76,12 @@ service Greeter {
 			t.Log(err)
 			return
 		}
-		pbDir, err := findPbFile(output, protoFile, false)
+		pbDir, err := findPbFile(output, false)
 		assert.Nil(t, err)
 		pbGo := filepath.Join(pbDir, "greet.pb.go")
 		assert.True(t, pathx.FileExists(pbGo))
 
-		grpcDir, err := findPbFile(output, protoFile, true)
+		grpcDir, err := findPbFile(output, true)
 		assert.Nil(t, err)
 		grpcGo := filepath.Join(grpcDir, "greet_grpc.pb.go")
 		assert.True(t, pathx.FileExists(grpcGo))
@@ -108,12 +108,12 @@ service Greeter {
 			t.Log(err)
 			return
 		}
-		pbDir, err := findPbFile(output, protoFile, false)
+		pbDir, err := findPbFile(output, false)
 		assert.Nil(t, err)
 		pbGo := filepath.Join(pbDir, "greet.pb.go")
 		assert.True(t, pathx.FileExists(pbGo))
 
-		grpcDir, err := findPbFile(output, protoFile, true)
+		grpcDir, err := findPbFile(output, true)
 		assert.Nil(t, err)
 		grpcGo := filepath.Join(grpcDir, "greet_grpc.pb.go")
 		assert.True(t, pathx.FileExists(grpcGo))
@@ -140,12 +140,12 @@ service Greeter {
 			t.Log(err)
 			return
 		}
-		pbDir, err := findPbFile(output, protoFile, false)
+		pbDir, err := findPbFile(output, false)
 		assert.Nil(t, err)
 		pbGo := filepath.Join(pbDir, "greet.pb.go")
 		assert.True(t, pathx.FileExists(pbGo))
 
-		grpcDir, err := findPbFile(output, protoFile, true)
+		grpcDir, err := findPbFile(output, true)
 		assert.Nil(t, err)
 		grpcGo := filepath.Join(grpcDir, "greet_grpc.pb.go")
 		assert.True(t, pathx.FileExists(grpcGo))
@@ -183,12 +183,12 @@ service Greeter {
 			t.Log(err)
 			return
 		}
-		pbDir, err := findPbFile(output, protoFile, false)
+		pbDir, err := findPbFile(output, false)
 		assert.Nil(t, err)
 		pbGo := filepath.Join(pbDir, "greet.pb.go")
 		assert.True(t, pathx.FileExists(pbGo))
 
-		grpcDir, err := findPbFile(output, protoFile, true)
+		grpcDir, err := findPbFile(output, true)
 		assert.Nil(t, err)
 		grpcGo := filepath.Join(grpcDir, "greet_grpc.pb.go")
 		assert.True(t, pathx.FileExists(grpcGo))

+ 1 - 1
tools/goctlwt/rpc/generator/logic.tpl

@@ -5,7 +5,7 @@ import (
 
 	{{.imports}}
 
-	"github.com/wuntsong-org/go-zero-plus/core/logx"
+	"github.com/zeromicro/go-zero/core/logx"
 )
 
 type {{.logicName}} struct {

+ 3 - 3
tools/goctlwt/rpc/generator/main.tpl

@@ -6,9 +6,9 @@ import (
 
 	{{.imports}}
 
-	"github.com/wuntsong-org/go-zero-plus/core/conf"
-	"github.com/wuntsong-org/go-zero-plus/core/service"
-	"github.com/wuntsong-org/go-zero-plus/zrpc"
+	"github.com/zeromicro/go-zero/core/conf"
+	"github.com/zeromicro/go-zero/core/service"
+	"github.com/zeromicro/go-zero/zrpc"
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/reflection"
 )

+ 1 - 1
tools/goctlwt/rpc/generator/template.go

@@ -35,7 +35,7 @@ var templates = map[string]string{
 	rpcTemplateFile:           rpcTemplateText,
 }
 
-// GenTemplates is the entry for command goctl template,
+// GenTemplates is the entry for command goctlwt template,
 // it will create the specified category
 func GenTemplates() error {
 	return pathx.InitTemplates(category, templates)

+ 2 - 2
tools/goctlwt/test/integration/model/mongo/Dockerfile

@@ -1,4 +1,4 @@
-FROM golang:1.19
+FROM golang:1.18
 
 ENV TZ Asia/Shanghai
 ENV GOPROXY https://goproxy.cn,direct
@@ -7,6 +7,6 @@ WORKDIR /app
 ADD goctl /usr/bin/goctl
 ADD cmd.sh .
 
-RUN chmod +x /usr/bin/goctl
+RUN chmod +x /usr/bin/goctlwt
 RUN chmod +x cmd.sh
 CMD ["/bin/bash", "cmd.sh"]

+ 4 - 4
tools/goctlwt/test/integration/model/mongo/mongo.sh

@@ -7,12 +7,12 @@ source ../../../common/echo.sh
 
 console_tip "mongo  test"
 
-# build goctl
+# build goctlwt
 console_step "goctl building"
 
-buildFile=goctl
-CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $buildFile ../../../../goctl.go
-image=goctl-mongo:latest
+buildFile=goctlwt
+CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $buildFile ../../../../goctlwt.go
+image=goctlwt-mongo:latest
 
 # docker build
 console_step "docker building"

+ 1 - 1
tools/goctlwt/test/main.sh

@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# main.sh is the entry point for the goctl tests.
+# main.sh is the entry point for the goctlwt tests.
 
 # testing mongo code generation.
 /bin/bash integration/model/mongo/mongo.sh

+ 1 - 1
tools/goctlwt/update/config/config.go

@@ -2,7 +2,7 @@ package config
 
 import "github.com/wuntsong-org/go-zero-plus/core/logx"
 
-// Config defines a service configure for goctl update
+// Config defines a service configure for goctlwt update
 type Config struct {
 	logx.LogConf
 	ListenOn string

+ 1 - 1
tools/goctlwt/update/update.go

@@ -15,7 +15,7 @@ import (
 
 const (
 	contentMd5Header = "Content-Md5"
-	filename         = "goctl"
+	filename         = "goctlwt"
 )
 
 var configFile = flag.String("f", "etc/update-api.json", "the config file")

+ 4 - 4
tools/goctlwt/upgrade/upgrade.go

@@ -8,12 +8,12 @@ import (
 	"github.com/wuntsong-org/go-zero-plus/tools/goctlwt/rpc/execx"
 )
 
-// upgrade gets the latest goctl by
-// go install github.com/wuntsong-org/go-zero-plus/tools/goctlwt@latest
+// upgrade gets the latest goctlwt by
+// go install github.com/zeromicro/go-zero/tools/goctlwt@latest
 func upgrade(_ *cobra.Command, _ []string) error {
-	cmd := `GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go install github.com/wuntsong-org/go-zero-plus/tools/goctlwt@latest`
+	cmd := `GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go install github.com/wuntsong-org/go-zero-plus/tools/goctlwtwt@latest`
 	if runtime.GOOS == "windows" {
-		cmd = `set GOPROXY=https://goproxy.cn,direct && go install github.com/wuntsong-org/go-zero-plus/tools/goctlwt@latest`
+		cmd = `set GOPROXY=https://goproxy.cn,direct && go install github.com/wuntsong-org/go-zero-plus/tools/goctlwtwt@latest`
 	}
 	info, err := execx.Run(cmd, "")
 	if err != nil {

+ 1 - 1
tools/goctlwt/util/ctx/context.go

@@ -17,7 +17,7 @@ type ProjectContext struct {
 	// eg: go-zero、greet
 	Name string
 	// Path identifies which module a project belongs to, which is module value if it's a go mod project,
-	// or else it is the root name of the project, eg: github.com/wuntsong-org/go-zero-plus、greet
+	// or else it is the root name of the project, eg: github.com/zeromicro/go-zero、greet
 	Path string
 	// Dir is the path of the project, eg: /Users/keson/goland/go/go-zero、/Users/keson/go/src/greet
 	Dir string

+ 9 - 9
tools/goctlwt/util/ctx/gomod_test.go

@@ -81,13 +81,13 @@ func Test_getRealModule(t *testing.T) {
 						"Path":"foo",
 						"Dir":"/home/foo",
 						"GoMod":"/home/foo/go.mod",
-						"GoVersion":"go1.19"
+						"GoVersion":"go1.18"
 					}
 					{
 						"Path":"bar",
 						"Dir":"/home/bar",
 						"GoMod":"/home/bar/go.mod",
-						"GoVersion":"go1.19"
+						"GoVersion":"go1.18"
 					}`, nil
 				},
 			},
@@ -95,7 +95,7 @@ func Test_getRealModule(t *testing.T) {
 				Path:      "bar",
 				Dir:       "/home/bar",
 				GoMod:     "/home/bar/go.mod",
-				GoVersion: "go1.19",
+				GoVersion: "go1.18",
 			},
 		},
 	}
@@ -143,26 +143,26 @@ func TestDecodePackages(t *testing.T) {
 						"Path":"foo",
 						"Dir":"/home/foo",
 						"GoMod":"/home/foo/go.mod",
-						"GoVersion":"go1.19"
+						"GoVersion":"go1.18"
 					}
 					{
 						"Path":"bar",
 						"Dir":"/home/bar",
 						"GoMod":"/home/bar/go.mod",
-						"GoVersion":"go1.19"
+						"GoVersion":"go1.18"
 					}`),
 			want: []Module{
 				{
 					Path:      "foo",
 					Dir:       "/home/foo",
 					GoMod:     "/home/foo/go.mod",
-					GoVersion: "go1.19",
+					GoVersion: "go1.18",
 				},
 				{
 					Path:      "bar",
 					Dir:       "/home/bar",
 					GoMod:     "/home/bar/go.mod",
-					GoVersion: "go1.19",
+					GoVersion: "go1.18",
 				},
 			},
 		},
@@ -173,14 +173,14 @@ func TestDecodePackages(t *testing.T) {
 						"Path":"foo",
 						"Dir":"/home/foo",
 						"GoMod":"/home/foo/go.mod",
-						"GoVersion":"go1.19"
+						"GoVersion":"go1.18"
 					}`),
 			want: []Module{
 				{
 					Path:      "foo",
 					Dir:       "/home/foo",
 					GoMod:     "/home/foo/go.mod",
-					GoVersion: "go1.19",
+					GoVersion: "go1.18",
 				},
 			},
 		},

+ 1 - 1
tools/goctlwt/util/head.go

@@ -2,7 +2,7 @@ package util
 
 const (
 	// DoNotEditHead added to the beginning of a file to prompt the user not to edit
-	DoNotEditHead = "// Code generated by goctl. DO NOT EDIT."
+	DoNotEditHead = "// Code generated by goctlwt. DO NOT EDIT."
 
 	headTemplate = DoNotEditHead + `
 // Source: {{.source}}`

Some files were not shown because too many files changed in this diff