mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-13 18:00:00 +08:00
chore: update go-zero version (#5093)
Signed-off-by: kevin <wanjunfeng@gmail.com>
This commit is contained in:
@@ -157,6 +157,7 @@ func validateOptions(value reflect.Value, opt *fieldOptions) error {
|
|||||||
if !slices.Contains(opt.Options, val) {
|
if !slices.Contains(opt.Options, val) {
|
||||||
return fmt.Errorf("field %q not in options", val)
|
return fmt.Errorf("field %q not in options", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -226,8 +226,8 @@ func formatDuration(duration time.Duration) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func genRouteImports(parentPkg string, api *spec.ApiSpec) string {
|
func genRouteImports(parentPkg string, api *spec.ApiSpec) string {
|
||||||
importSet := collection.NewSet()
|
importSet := collection.NewSet[string]()
|
||||||
importSet.AddStr(fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, contextDir)))
|
importSet.Add(fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, contextDir)))
|
||||||
for _, group := range api.Service.Groups {
|
for _, group := range api.Service.Groups {
|
||||||
for _, route := range group.Routes {
|
for _, route := range group.Routes {
|
||||||
folder := route.GetAnnotation(groupProperty)
|
folder := route.GetAnnotation(groupProperty)
|
||||||
@@ -237,11 +237,11 @@ func genRouteImports(parentPkg string, api *spec.ApiSpec) string {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
importSet.AddStr(fmt.Sprintf("%s \"%s\"", toPrefix(folder),
|
importSet.Add(fmt.Sprintf("%s \"%s\"", toPrefix(folder),
|
||||||
pathx.JoinPackages(parentPkg, handlerDir, folder)))
|
pathx.JoinPackages(parentPkg, handlerDir, folder)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
imports := importSet.KeysStr()
|
imports := importSet.Keys()
|
||||||
sort.Strings(imports)
|
sort.Strings(imports)
|
||||||
projectSection := strings.Join(imports, "\n\t")
|
projectSection := strings.Join(imports, "\n\t")
|
||||||
depSection := fmt.Sprintf("\"%s/rest\"", vars.ProjectOpenSourceURL)
|
depSection := fmt.Sprintf("\"%s/rest\"", vars.ProjectOpenSourceURL)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ func getTypeName(tp spec.Type) string {
|
|||||||
|
|
||||||
func genTypesWithGroup(dir string, cfg *config.Config, api *spec.ApiSpec) error {
|
func genTypesWithGroup(dir string, cfg *config.Config, api *spec.ApiSpec) error {
|
||||||
groupTypes := make(map[string]map[string]spec.Type)
|
groupTypes := make(map[string]map[string]spec.Type)
|
||||||
typesBelongToFiles := make(map[string]*collection.Set)
|
typesBelongToFiles := make(map[string]*collection.Set[string])
|
||||||
|
|
||||||
for _, v := range api.Service.Groups {
|
for _, v := range api.Service.Groups {
|
||||||
group := v.GetAnnotation(groupProperty)
|
group := v.GetAnnotation(groupProperty)
|
||||||
@@ -75,37 +75,37 @@ func genTypesWithGroup(dir string, cfg *config.Config, api *spec.ApiSpec) error
|
|||||||
responseTypeName := getTypeName(v.ResponseType)
|
responseTypeName := getTypeName(v.ResponseType)
|
||||||
requestTypeFileSet, ok := typesBelongToFiles[requestTypeName]
|
requestTypeFileSet, ok := typesBelongToFiles[requestTypeName]
|
||||||
if !ok {
|
if !ok {
|
||||||
requestTypeFileSet = collection.NewSet()
|
requestTypeFileSet = collection.NewSet[string]()
|
||||||
}
|
}
|
||||||
if len(requestTypeName) > 0 {
|
if len(requestTypeName) > 0 {
|
||||||
requestTypeFileSet.AddStr(group)
|
requestTypeFileSet.Add(group)
|
||||||
typesBelongToFiles[requestTypeName] = requestTypeFileSet
|
typesBelongToFiles[requestTypeName] = requestTypeFileSet
|
||||||
}
|
}
|
||||||
|
|
||||||
responseTypeFileSet, ok := typesBelongToFiles[responseTypeName]
|
responseTypeFileSet, ok := typesBelongToFiles[responseTypeName]
|
||||||
if !ok {
|
if !ok {
|
||||||
responseTypeFileSet = collection.NewSet()
|
responseTypeFileSet = collection.NewSet[string]()
|
||||||
}
|
}
|
||||||
if len(responseTypeName) > 0 {
|
if len(responseTypeName) > 0 {
|
||||||
responseTypeFileSet.AddStr(group)
|
responseTypeFileSet.Add(group)
|
||||||
typesBelongToFiles[responseTypeName] = responseTypeFileSet
|
typesBelongToFiles[responseTypeName] = responseTypeFileSet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typesInOneFile := make(map[string]*collection.Set)
|
typesInOneFile := make(map[string]*collection.Set[string])
|
||||||
for typeName, fileSet := range typesBelongToFiles {
|
for typeName, fileSet := range typesBelongToFiles {
|
||||||
count := fileSet.Count()
|
count := fileSet.Count()
|
||||||
switch {
|
switch {
|
||||||
case count == 0: // it means there has no structure type or no request/response body
|
case count == 0: // it means there has no structure type or no request/response body
|
||||||
continue
|
continue
|
||||||
case count == 1: // it means a structure type used in only one group.
|
case count == 1: // it means a structure type used in only one group.
|
||||||
groupName := fileSet.KeysStr()[0]
|
groupName := fileSet.Keys()[0]
|
||||||
typeSet, ok := typesInOneFile[groupName]
|
typeSet, ok := typesInOneFile[groupName]
|
||||||
if !ok {
|
if !ok {
|
||||||
typeSet = collection.NewSet()
|
typeSet = collection.NewSet[string]()
|
||||||
}
|
}
|
||||||
typeSet.AddStr(typeName)
|
typeSet.Add(typeName)
|
||||||
typesInOneFile[groupName] = typeSet
|
typesInOneFile[groupName] = typeSet
|
||||||
default: // it means this type is used in multiple groups.
|
default: // it means this type is used in multiple groups.
|
||||||
continue
|
continue
|
||||||
@@ -133,7 +133,7 @@ func genTypesWithGroup(dir string, cfg *config.Config, api *spec.ApiSpec) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
if typeCount == 1 { // belong to one group
|
if typeCount == 1 { // belong to one group
|
||||||
groupName := groupSet.KeysStr()[0]
|
groupName := groupSet.Keys()[0]
|
||||||
types, ok := groupTypes[groupName]
|
types, ok := groupTypes[groupName]
|
||||||
if !ok {
|
if !ok {
|
||||||
types = make(map[string]spec.Type)
|
types = make(map[string]spec.Type)
|
||||||
|
|||||||
@@ -115,29 +115,29 @@ func writeProperty(writer io.Writer, name, tag, comment string, tp spec.Type, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getAuths(api *spec.ApiSpec) []string {
|
func getAuths(api *spec.ApiSpec) []string {
|
||||||
authNames := collection.NewSet()
|
authNames := collection.NewSet[string]()
|
||||||
for _, g := range api.Service.Groups {
|
for _, g := range api.Service.Groups {
|
||||||
jwt := g.GetAnnotation("jwt")
|
jwt := g.GetAnnotation("jwt")
|
||||||
if len(jwt) > 0 {
|
if len(jwt) > 0 {
|
||||||
authNames.Add(jwt)
|
authNames.Add(jwt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return authNames.KeysStr()
|
return authNames.Keys()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getJwtTrans(api *spec.ApiSpec) []string {
|
func getJwtTrans(api *spec.ApiSpec) []string {
|
||||||
jwtTransList := collection.NewSet()
|
jwtTransList := collection.NewSet[string]()
|
||||||
for _, g := range api.Service.Groups {
|
for _, g := range api.Service.Groups {
|
||||||
jt := g.GetAnnotation(jwtTransKey)
|
jt := g.GetAnnotation(jwtTransKey)
|
||||||
if len(jt) > 0 {
|
if len(jt) > 0 {
|
||||||
jwtTransList.Add(jt)
|
jwtTransList.Add(jt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return jwtTransList.KeysStr()
|
return jwtTransList.Keys()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMiddleware(api *spec.ApiSpec) []string {
|
func getMiddleware(api *spec.ApiSpec) []string {
|
||||||
result := collection.NewSet()
|
result := collection.NewSet[string]()
|
||||||
for _, g := range api.Service.Groups {
|
for _, g := range api.Service.Groups {
|
||||||
middleware := g.GetAnnotation("middleware")
|
middleware := g.GetAnnotation("middleware")
|
||||||
if len(middleware) > 0 {
|
if len(middleware) > 0 {
|
||||||
@@ -147,7 +147,7 @@ func getMiddleware(api *spec.ApiSpec) []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.KeysStr()
|
return result.Keys()
|
||||||
}
|
}
|
||||||
|
|
||||||
func responseGoTypeName(r spec.Route, pkg ...string) string {
|
func responseGoTypeName(r spec.Route, pkg ...string) string {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ require (
|
|||||||
github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1
|
github.com/withfig/autocomplete-tools/integrations/cobra v1.2.1
|
||||||
github.com/zeromicro/antlr v0.0.1
|
github.com/zeromicro/antlr v0.0.1
|
||||||
github.com/zeromicro/ddl-parser v1.0.5
|
github.com/zeromicro/ddl-parser v1.0.5
|
||||||
github.com/zeromicro/go-zero v1.8.5
|
github.com/zeromicro/go-zero v1.9.0
|
||||||
golang.org/x/text v0.22.0
|
golang.org/x/text v0.22.0
|
||||||
google.golang.org/grpc v1.65.0
|
google.golang.org/grpc v1.65.0
|
||||||
google.golang.org/protobuf v1.36.5
|
google.golang.org/protobuf v1.36.5
|
||||||
@@ -42,13 +42,12 @@ require (
|
|||||||
github.com/go-openapi/jsonreference v0.21.0 // indirect
|
github.com/go-openapi/jsonreference v0.21.0 // indirect
|
||||||
github.com/go-openapi/swag v0.23.1 // indirect
|
github.com/go-openapi/swag v0.23.1 // indirect
|
||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang/mock v1.6.0 // indirect
|
|
||||||
github.com/golang/protobuf v1.5.4 // indirect
|
github.com/golang/protobuf v1.5.4 // indirect
|
||||||
github.com/google/gnostic-models v0.6.8 // indirect
|
github.com/google/gnostic-models v0.6.8 // indirect
|
||||||
github.com/google/go-cmp v0.6.0 // indirect
|
github.com/google/go-cmp v0.6.0 // indirect
|
||||||
github.com/google/gofuzz v1.2.0 // indirect
|
github.com/google/gofuzz v1.2.0 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/grafana/pyroscope-go v1.2.2 // indirect
|
github.com/grafana/pyroscope-go v1.2.4 // indirect
|
||||||
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 // indirect
|
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
@@ -73,7 +72,7 @@ require (
|
|||||||
github.com/prometheus/client_model v0.6.1 // indirect
|
github.com/prometheus/client_model v0.6.1 // indirect
|
||||||
github.com/prometheus/common v0.62.0 // indirect
|
github.com/prometheus/common v0.62.0 // indirect
|
||||||
github.com/prometheus/procfs v0.15.1 // indirect
|
github.com/prometheus/procfs v0.15.1 // indirect
|
||||||
github.com/redis/go-redis/v9 v9.11.0 // indirect
|
github.com/redis/go-redis/v9 v9.12.1 // indirect
|
||||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
|
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
|
||||||
github.com/yuin/gopher-lua v1.1.1 // indirect
|
github.com/yuin/gopher-lua v1.1.1 // indirect
|
||||||
@@ -93,6 +92,7 @@ require (
|
|||||||
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
|
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
|
||||||
go.uber.org/atomic v1.10.0 // indirect
|
go.uber.org/atomic v1.10.0 // indirect
|
||||||
go.uber.org/automaxprocs v1.6.0 // indirect
|
go.uber.org/automaxprocs v1.6.0 // indirect
|
||||||
|
go.uber.org/mock v0.4.0 // indirect
|
||||||
go.uber.org/multierr v1.9.0 // indirect
|
go.uber.org/multierr v1.9.0 // indirect
|
||||||
go.uber.org/zap v1.24.0 // indirect
|
go.uber.org/zap v1.24.0 // indirect
|
||||||
golang.org/x/crypto v0.33.0 // indirect
|
golang.org/x/crypto v0.33.0 // indirect
|
||||||
|
|||||||
@@ -57,8 +57,6 @@ github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4
|
|||||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
|
|
||||||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
|
||||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||||
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
|
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
|
||||||
@@ -75,8 +73,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
|||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
|
github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
|
||||||
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
|
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
|
||||||
github.com/grafana/pyroscope-go v1.2.2 h1:uvKCyZMD724RkaCEMrSTC38Yn7AnFe8S2wiAIYdDPCE=
|
github.com/grafana/pyroscope-go v1.2.4 h1:B22GMXz+O0nWLatxLuaP7o7L9dvP0clLvIpmeEQQM0Q=
|
||||||
github.com/grafana/pyroscope-go v1.2.2/go.mod h1:zzT9QXQAp2Iz2ZdS216UiV8y9uXJYQiGE1q8v1FyhqU=
|
github.com/grafana/pyroscope-go v1.2.4/go.mod h1:zzT9QXQAp2Iz2ZdS216UiV8y9uXJYQiGE1q8v1FyhqU=
|
||||||
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 h1:iwOtYXeeVSAeYefJNaxDytgjKtUuKQbJqgAIjlnicKg=
|
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 h1:iwOtYXeeVSAeYefJNaxDytgjKtUuKQbJqgAIjlnicKg=
|
||||||
github.com/grafana/pyroscope-go/godeltaprof v0.1.8/go.mod h1:2+l7K7twW49Ct4wFluZD3tZ6e0SjanjcUUBPVD/UuGU=
|
github.com/grafana/pyroscope-go/godeltaprof v0.1.8/go.mod h1:2+l7K7twW49Ct4wFluZD3tZ6e0SjanjcUUBPVD/UuGU=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
|
||||||
@@ -148,8 +146,8 @@ github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ
|
|||||||
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
|
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
|
||||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||||
github.com/redis/go-redis/v9 v9.11.0 h1:E3S08Gl/nJNn5vkxd2i78wZxWAPNZgUNTp8WIJUAiIs=
|
github.com/redis/go-redis/v9 v9.12.1 h1:k5iquqv27aBtnTm2tIkROUDp8JBXhXZIVu1InSgvovg=
|
||||||
github.com/redis/go-redis/v9 v9.11.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
|
github.com/redis/go-redis/v9 v9.12.1/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
|
||||||
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
|
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
|
||||||
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
@@ -179,15 +177,14 @@ github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHg
|
|||||||
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
|
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=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
|
||||||
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
|
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
|
||||||
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
|
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
|
||||||
github.com/zeromicro/antlr v0.0.1 h1:CQpIn/dc0pUjgGQ81y98s/NGOm2Hfru2NNio2I9mQgk=
|
github.com/zeromicro/antlr v0.0.1 h1:CQpIn/dc0pUjgGQ81y98s/NGOm2Hfru2NNio2I9mQgk=
|
||||||
github.com/zeromicro/antlr v0.0.1/go.mod h1:nfpjEwFR6Q4xGDJMcZnCL9tEfQRgszMwu3rDz2Z+p5M=
|
github.com/zeromicro/antlr v0.0.1/go.mod h1:nfpjEwFR6Q4xGDJMcZnCL9tEfQRgszMwu3rDz2Z+p5M=
|
||||||
github.com/zeromicro/ddl-parser v1.0.5 h1:LaVqHdzMTjasua1yYpIYaksxKqRzFrEukj2Wi2EbWaQ=
|
github.com/zeromicro/ddl-parser v1.0.5 h1:LaVqHdzMTjasua1yYpIYaksxKqRzFrEukj2Wi2EbWaQ=
|
||||||
github.com/zeromicro/ddl-parser v1.0.5/go.mod h1:ISU/8NuPyEpl9pa17Py9TBPetMjtsiHrb9f5XGiYbo8=
|
github.com/zeromicro/ddl-parser v1.0.5/go.mod h1:ISU/8NuPyEpl9pa17Py9TBPetMjtsiHrb9f5XGiYbo8=
|
||||||
github.com/zeromicro/go-zero v1.8.5 h1:YkdQhYllE+BPOrxcni0oCewebs7qHfXvjN9glnpcmJQ=
|
github.com/zeromicro/go-zero v1.9.0 h1:hlVtQCSHPszQdcwZTawzGwTej1G2mhHybYzMRLuwCt4=
|
||||||
github.com/zeromicro/go-zero v1.8.5/go.mod h1:P0DKW1vJx+2J3TReptbeg0H9tRSvehymr0HX4SCfZ6g=
|
github.com/zeromicro/go-zero v1.9.0/go.mod h1:TMyCxiaOjLQ3YxyYlJrejaQZF40RlzQ3FVvFu5EbcV4=
|
||||||
go.etcd.io/etcd/api/v3 v3.5.15 h1:3KpLJir1ZEBrYuV2v+Twaa/e2MdDCEZ/70H+lzEiwsk=
|
go.etcd.io/etcd/api/v3 v3.5.15 h1:3KpLJir1ZEBrYuV2v+Twaa/e2MdDCEZ/70H+lzEiwsk=
|
||||||
go.etcd.io/etcd/api/v3 v3.5.15/go.mod h1:N9EhGzXq58WuMllgH9ZvnEr7SI9pS0k0+DHZezGp7jM=
|
go.etcd.io/etcd/api/v3 v3.5.15/go.mod h1:N9EhGzXq58WuMllgH9ZvnEr7SI9pS0k0+DHZezGp7jM=
|
||||||
go.etcd.io/etcd/client/pkg/v3 v3.5.15 h1:fo0HpWz/KlHGMCC+YejpiCmyWDEuIpnTDzpJLB5fWlA=
|
go.etcd.io/etcd/client/pkg/v3 v3.5.15 h1:fo0HpWz/KlHGMCC+YejpiCmyWDEuIpnTDzpJLB5fWlA=
|
||||||
@@ -222,6 +219,8 @@ go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
|
|||||||
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
|
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
|
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
|
||||||
|
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
|
||||||
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
|
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
|
||||||
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
|
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
|
||||||
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
|
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
|
||||||
@@ -233,12 +232,10 @@ golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
|
|||||||
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
|
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
|
||||||
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
||||||
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
||||||
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
|
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
|
||||||
@@ -246,20 +243,15 @@ golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbht
|
|||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
|
||||||
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
|
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
|
||||||
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/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-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
|
||||||
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
|
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
|
||||||
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
|
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
@@ -272,7 +264,6 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
|
|||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
|
||||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
|
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
|
||||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
|||||||
@@ -145,14 +145,14 @@ func MySqlDataSource(_ *cobra.Command, _ []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func mergeColumns(columns []string) []string {
|
func mergeColumns(columns []string) []string {
|
||||||
set := collection.NewSet()
|
set := collection.NewSet[string]()
|
||||||
for _, v := range columns {
|
for _, v := range columns {
|
||||||
fields := strings.FieldsFunc(v, func(r rune) bool {
|
fields := strings.FieldsFunc(v, func(r rune) bool {
|
||||||
return r == ','
|
return r == ','
|
||||||
})
|
})
|
||||||
set.AddStr(fields...)
|
set.Add(fields...)
|
||||||
}
|
}
|
||||||
return set.KeysStr()
|
return set.Keys()
|
||||||
}
|
}
|
||||||
|
|
||||||
type pattern map[string]struct{}
|
type pattern map[string]struct{}
|
||||||
|
|||||||
@@ -60,17 +60,17 @@ func genCustomized(table Table, withCache, postgreSql bool) (string, error) {
|
|||||||
fields = append(fields, f)
|
fields = append(fields, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
keySet := collection.NewSet()
|
keySet := collection.NewSet[string]()
|
||||||
keyVariableSet := collection.NewSet()
|
keyVariableSet := collection.NewSet[string]()
|
||||||
keySet.AddStr(table.PrimaryCacheKey.KeyExpression)
|
keySet.Add(table.PrimaryCacheKey.KeyExpression)
|
||||||
keyVariableSet.AddStr(table.PrimaryCacheKey.KeyLeft)
|
keyVariableSet.Add(table.PrimaryCacheKey.KeyLeft)
|
||||||
for _, key := range table.UniqueCacheKey {
|
for _, key := range table.UniqueCacheKey {
|
||||||
keySet.AddStr(key.DataKeyExpression)
|
keySet.Add(key.DataKeyExpression)
|
||||||
keyVariableSet.AddStr(key.KeyLeft)
|
keyVariableSet.Add(key.KeyLeft)
|
||||||
}
|
}
|
||||||
keys := keySet.KeysStr()
|
keys := keySet.Keys()
|
||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
keyVars := keyVariableSet.KeysStr()
|
keyVars := keyVariableSet.Keys()
|
||||||
sort.Strings(keyVars)
|
sort.Strings(keyVars)
|
||||||
|
|
||||||
camel := table.Name.ToCamel()
|
camel := table.Name.ToCamel()
|
||||||
|
|||||||
@@ -12,17 +12,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func genDelete(table Table, withCache, postgreSql bool) (string, string, error) {
|
func genDelete(table Table, withCache, postgreSql bool) (string, string, error) {
|
||||||
keySet := collection.NewSet()
|
keySet := collection.NewSet[string]()
|
||||||
keyVariableSet := collection.NewSet()
|
keyVariableSet := collection.NewSet[string]()
|
||||||
keySet.AddStr(table.PrimaryCacheKey.KeyExpression)
|
keySet.Add(table.PrimaryCacheKey.KeyExpression)
|
||||||
keyVariableSet.AddStr(table.PrimaryCacheKey.KeyLeft)
|
keyVariableSet.Add(table.PrimaryCacheKey.KeyLeft)
|
||||||
for _, key := range table.UniqueCacheKey {
|
for _, key := range table.UniqueCacheKey {
|
||||||
keySet.AddStr(key.DataKeyExpression)
|
keySet.Add(key.DataKeyExpression)
|
||||||
keyVariableSet.AddStr(key.KeyLeft)
|
keyVariableSet.Add(key.KeyLeft)
|
||||||
}
|
}
|
||||||
keys := keySet.KeysStr()
|
keys := keySet.Keys()
|
||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
keyVars := keyVariableSet.KeysStr()
|
keyVars := keyVariableSet.Keys()
|
||||||
sort.Strings(keyVars)
|
sort.Strings(keyVars)
|
||||||
|
|
||||||
camel := table.Name.ToCamel()
|
camel := table.Name.ToCamel()
|
||||||
|
|||||||
@@ -13,17 +13,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func genInsert(table Table, withCache, postgreSql bool) (string, string, error) {
|
func genInsert(table Table, withCache, postgreSql bool) (string, string, error) {
|
||||||
keySet := collection.NewSet()
|
keySet := collection.NewSet[string]()
|
||||||
keyVariableSet := collection.NewSet()
|
keyVariableSet := collection.NewSet[string]()
|
||||||
keySet.AddStr(table.PrimaryCacheKey.DataKeyExpression)
|
keySet.Add(table.PrimaryCacheKey.DataKeyExpression)
|
||||||
keyVariableSet.AddStr(table.PrimaryCacheKey.KeyLeft)
|
keyVariableSet.Add(table.PrimaryCacheKey.KeyLeft)
|
||||||
for _, key := range table.UniqueCacheKey {
|
for _, key := range table.UniqueCacheKey {
|
||||||
keySet.AddStr(key.DataKeyExpression)
|
keySet.Add(key.DataKeyExpression)
|
||||||
keyVariableSet.AddStr(key.KeyLeft)
|
keyVariableSet.Add(key.KeyLeft)
|
||||||
}
|
}
|
||||||
keys := keySet.KeysStr()
|
keys := keySet.Keys()
|
||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
keyVars := keyVariableSet.KeysStr()
|
keyVars := keyVariableSet.Keys()
|
||||||
sort.Strings(keyVars)
|
sort.Strings(keyVars)
|
||||||
|
|
||||||
expressions := make([]string, 0)
|
expressions := make([]string, 0)
|
||||||
|
|||||||
@@ -32,17 +32,17 @@ func genUpdate(table Table, withCache, postgreSql bool) (
|
|||||||
expressionValues = append(expressionValues, pkg+camel)
|
expressionValues = append(expressionValues, pkg+camel)
|
||||||
}
|
}
|
||||||
|
|
||||||
keySet := collection.NewSet()
|
keySet := collection.NewSet[string]()
|
||||||
keyVariableSet := collection.NewSet()
|
keyVariableSet := collection.NewSet[string]()
|
||||||
keySet.AddStr(table.PrimaryCacheKey.DataKeyExpression)
|
keySet.Add(table.PrimaryCacheKey.DataKeyExpression)
|
||||||
keyVariableSet.AddStr(table.PrimaryCacheKey.KeyLeft)
|
keyVariableSet.Add(table.PrimaryCacheKey.KeyLeft)
|
||||||
for _, key := range table.UniqueCacheKey {
|
for _, key := range table.UniqueCacheKey {
|
||||||
keySet.AddStr(key.DataKeyExpression)
|
keySet.Add(key.DataKeyExpression)
|
||||||
keyVariableSet.AddStr(key.KeyLeft)
|
keyVariableSet.Add(key.KeyLeft)
|
||||||
}
|
}
|
||||||
keys := keySet.KeysStr()
|
keys := keySet.Keys()
|
||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
keyVars := keyVariableSet.KeysStr()
|
keyVars := keyVariableSet.Keys()
|
||||||
sort.Strings(keyVars)
|
sort.Strings(keyVars)
|
||||||
|
|
||||||
if postgreSql {
|
if postgreSql {
|
||||||
|
|||||||
@@ -36,15 +36,15 @@ func genVars(table Table, withCache, postgreSql bool) (string, error) {
|
|||||||
"postgreSql": postgreSql,
|
"postgreSql": postgreSql,
|
||||||
"data": table,
|
"data": table,
|
||||||
"ignoreColumns": func() string {
|
"ignoreColumns": func() string {
|
||||||
var set = collection.NewSet()
|
var set = collection.NewSet[string]()
|
||||||
for _, c := range table.ignoreColumns {
|
for _, c := range table.ignoreColumns {
|
||||||
if postgreSql {
|
if postgreSql {
|
||||||
set.AddStr(fmt.Sprintf(`"%s"`, c))
|
set.Add(fmt.Sprintf(`"%s"`, c))
|
||||||
} else {
|
} else {
|
||||||
set.AddStr(fmt.Sprintf("\"`%s`\"", c))
|
set.Add(fmt.Sprintf("\"`%s`\"", c))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list := set.KeysStr()
|
list := set.Keys()
|
||||||
sort.Strings(list)
|
sort.Strings(list)
|
||||||
return strings.Join(list, ", ")
|
return strings.Join(list, ", ")
|
||||||
}(),
|
}(),
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ func Parse(filename, database string, strict bool) ([]*Table, error) {
|
|||||||
for indexTable, e := range tables {
|
for indexTable, e := range tables {
|
||||||
var (
|
var (
|
||||||
primaryColumn string
|
primaryColumn string
|
||||||
primaryColumnSet = collection.NewSet()
|
primaryColumnSet = collection.NewSet[string]()
|
||||||
uniqueKeyMap = make(map[string][]string)
|
uniqueKeyMap = make(map[string][]string)
|
||||||
// Unused local variable
|
// Unused local variable
|
||||||
// normalKeyMap = make(map[string][]string)
|
// normalKeyMap = make(map[string][]string)
|
||||||
@@ -91,7 +91,7 @@ func Parse(filename, database string, strict bool) ([]*Table, error) {
|
|||||||
for _, column := range columns {
|
for _, column := range columns {
|
||||||
if column.Constraint != nil {
|
if column.Constraint != nil {
|
||||||
if column.Constraint.Primary {
|
if column.Constraint.Primary {
|
||||||
primaryColumnSet.AddStr(column.Name)
|
primaryColumnSet.Add(column.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if column.Constraint.Unique {
|
if column.Constraint.Unique {
|
||||||
@@ -113,7 +113,7 @@ func Parse(filename, database string, strict bool) ([]*Table, error) {
|
|||||||
|
|
||||||
if len(e.ColumnPrimaryKey) == 1 {
|
if len(e.ColumnPrimaryKey) == 1 {
|
||||||
primaryColumn = e.ColumnPrimaryKey[0]
|
primaryColumn = e.ColumnPrimaryKey[0]
|
||||||
primaryColumnSet.AddStr(e.ColumnPrimaryKey[0])
|
primaryColumnSet.Add(e.ColumnPrimaryKey[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(e.ColumnUniqueKey) > 0 {
|
if len(e.ColumnUniqueKey) > 0 {
|
||||||
@@ -173,7 +173,7 @@ func Parse(filename, database string, strict bool) ([]*Table, error) {
|
|||||||
|
|
||||||
func checkDuplicateUniqueIndex(uniqueIndex map[string][]*Field, tableName string) {
|
func checkDuplicateUniqueIndex(uniqueIndex map[string][]*Field, tableName string) {
|
||||||
log := console.NewColorConsole()
|
log := console.NewColorConsole()
|
||||||
uniqueSet := collection.NewSet()
|
uniqueSet := collection.NewSet[string]()
|
||||||
for k, i := range uniqueIndex {
|
for k, i := range uniqueIndex {
|
||||||
var list []string
|
var list []string
|
||||||
for _, e := range i {
|
for _, e := range i {
|
||||||
@@ -187,7 +187,7 @@ func checkDuplicateUniqueIndex(uniqueIndex map[string][]*Field, tableName string
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
uniqueSet.AddStr(joinRet)
|
uniqueSet.Add(joinRet)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,7 +311,7 @@ func ConvertDataType(table *model.Table, strict bool) (*Table, error) {
|
|||||||
return reply.Fields[i].OrdinalPosition < reply.Fields[j].OrdinalPosition
|
return reply.Fields[i].OrdinalPosition < reply.Fields[j].OrdinalPosition
|
||||||
})
|
})
|
||||||
|
|
||||||
uniqueIndexSet := collection.NewSet()
|
uniqueIndexSet := collection.NewSet[string]()
|
||||||
log := console.NewColorConsole()
|
log := console.NewColorConsole()
|
||||||
for indexName, each := range table.UniqueIndex {
|
for indexName, each := range table.UniqueIndex {
|
||||||
sort.Slice(each, func(i, j int) bool {
|
sort.Slice(each, func(i, j int) bool {
|
||||||
@@ -342,7 +342,7 @@ func ConvertDataType(table *model.Table, strict bool) (*Table, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
uniqueIndexSet.AddStr(uniqueKey)
|
uniqueIndexSet.Add(uniqueKey)
|
||||||
reply.UniqueIndex[indexName] = list
|
reply.UniqueIndex[indexName] = list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func (g *Generator) genCallGroup(ctx DirContext, proto parser.Proto, cfg *conf.C
|
|||||||
isCallPkgSameToGrpcPkg := childDir == ctx.GetProtoGo().Filename
|
isCallPkgSameToGrpcPkg := childDir == ctx.GetProtoGo().Filename
|
||||||
|
|
||||||
serviceName := stringx.From(service.Name).ToCamel()
|
serviceName := stringx.From(service.Name).ToCamel()
|
||||||
alias := collection.NewSet()
|
alias := collection.NewSet[string]()
|
||||||
var hasSameNameBetweenMessageAndService bool
|
var hasSameNameBetweenMessageAndService bool
|
||||||
for _, item := range proto.Message {
|
for _, item := range proto.Message {
|
||||||
msgName := getMessageName(*item.Message)
|
msgName := getMessageName(*item.Message)
|
||||||
@@ -72,7 +72,7 @@ func (g *Generator) genCallGroup(ctx DirContext, proto parser.Proto, cfg *conf.C
|
|||||||
hasSameNameBetweenMessageAndService = true
|
hasSameNameBetweenMessageAndService = true
|
||||||
}
|
}
|
||||||
if !isCallPkgSameToPbPkg {
|
if !isCallPkgSameToPbPkg {
|
||||||
alias.AddStr(fmt.Sprintf("%s = %s", parser.CamelCase(msgName),
|
alias.Add(fmt.Sprintf("%s = %s", parser.CamelCase(msgName),
|
||||||
fmt.Sprintf("%s.%s", proto.PbPackage, parser.CamelCase(msgName))))
|
fmt.Sprintf("%s.%s", proto.PbPackage, parser.CamelCase(msgName))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ func (g *Generator) genCallGroup(ctx DirContext, proto parser.Proto, cfg *conf.C
|
|||||||
protoGoPackage = ""
|
protoGoPackage = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
aliasKeys := alias.KeysStr()
|
aliasKeys := alias.Keys()
|
||||||
sort.Strings(aliasKeys)
|
sort.Strings(aliasKeys)
|
||||||
if err = util.With("shared").GoFmt(true).Parse(text).SaveTo(map[string]any{
|
if err = util.With("shared").GoFmt(true).Parse(text).SaveTo(map[string]any{
|
||||||
"name": callFilename,
|
"name": callFilename,
|
||||||
@@ -135,7 +135,7 @@ func (g *Generator) genCallInCompatibility(ctx DirContext, proto parser.Proto,
|
|||||||
}
|
}
|
||||||
|
|
||||||
serviceName := stringx.From(service.Name).ToCamel()
|
serviceName := stringx.From(service.Name).ToCamel()
|
||||||
alias := collection.NewSet()
|
alias := collection.NewSet[string]()
|
||||||
var hasSameNameBetweenMessageAndService bool
|
var hasSameNameBetweenMessageAndService bool
|
||||||
for _, item := range proto.Message {
|
for _, item := range proto.Message {
|
||||||
msgName := getMessageName(*item.Message)
|
msgName := getMessageName(*item.Message)
|
||||||
@@ -143,7 +143,7 @@ func (g *Generator) genCallInCompatibility(ctx DirContext, proto parser.Proto,
|
|||||||
hasSameNameBetweenMessageAndService = true
|
hasSameNameBetweenMessageAndService = true
|
||||||
}
|
}
|
||||||
if !isCallPkgSameToPbPkg {
|
if !isCallPkgSameToPbPkg {
|
||||||
alias.AddStr(fmt.Sprintf("%s = %s", parser.CamelCase(msgName),
|
alias.Add(fmt.Sprintf("%s = %s", parser.CamelCase(msgName),
|
||||||
fmt.Sprintf("%s.%s", proto.PbPackage, parser.CamelCase(msgName))))
|
fmt.Sprintf("%s.%s", proto.PbPackage, parser.CamelCase(msgName))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,7 +174,7 @@ func (g *Generator) genCallInCompatibility(ctx DirContext, proto parser.Proto,
|
|||||||
pbPackage = ""
|
pbPackage = ""
|
||||||
protoGoPackage = ""
|
protoGoPackage = ""
|
||||||
}
|
}
|
||||||
aliasKeys := alias.KeysStr()
|
aliasKeys := alias.Keys()
|
||||||
sort.Strings(aliasKeys)
|
sort.Strings(aliasKeys)
|
||||||
return util.With("shared").GoFmt(true).Parse(text).SaveTo(map[string]any{
|
return util.With("shared").GoFmt(true).Parse(text).SaveTo(map[string]any{
|
||||||
"name": callFilename,
|
"name": callFilename,
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ func (g *Generator) genLogicInCompatibility(ctx DirContext, proto parser.Proto,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
imports := collection.NewSet()
|
imports := collection.NewSet[string]()
|
||||||
imports.AddStr(fmt.Sprintf(`"%v"`, ctx.GetSvc().Package))
|
imports.Add(fmt.Sprintf(`"%v"`, ctx.GetSvc().Package))
|
||||||
imports.AddStr(fmt.Sprintf(`"%v"`, ctx.GetPb().Package))
|
imports.Add(fmt.Sprintf(`"%v"`, ctx.GetPb().Package))
|
||||||
text, err := pathx.LoadTemplate(category, logicTemplateFileFile, logicTemplate)
|
text, err := pathx.LoadTemplate(category, logicTemplateFileFile, logicTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -64,7 +64,7 @@ func (g *Generator) genLogicInCompatibility(ctx DirContext, proto parser.Proto,
|
|||||||
"logicName": fmt.Sprintf("%sLogic", stringx.From(rpc.Name).ToCamel()),
|
"logicName": fmt.Sprintf("%sLogic", stringx.From(rpc.Name).ToCamel()),
|
||||||
"functions": functions,
|
"functions": functions,
|
||||||
"packageName": "logic",
|
"packageName": "logic",
|
||||||
"imports": strings.Join(imports.KeysStr(), pathx.NL),
|
"imports": strings.Join(imports.Keys(), pathx.NL),
|
||||||
}, filename, false)
|
}, filename, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -106,9 +106,9 @@ func (g *Generator) genLogicGroup(ctx DirContext, proto parser.Proto, cfg *conf.
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
imports := collection.NewSet()
|
imports := collection.NewSet[string]()
|
||||||
imports.AddStr(fmt.Sprintf(`"%v"`, ctx.GetSvc().Package))
|
imports.Add(fmt.Sprintf(`"%v"`, ctx.GetSvc().Package))
|
||||||
imports.AddStr(fmt.Sprintf(`"%v"`, ctx.GetPb().Package))
|
imports.Add(fmt.Sprintf(`"%v"`, ctx.GetPb().Package))
|
||||||
text, err := pathx.LoadTemplate(category, logicTemplateFileFile, logicTemplate)
|
text, err := pathx.LoadTemplate(category, logicTemplateFileFile, logicTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -118,7 +118,7 @@ func (g *Generator) genLogicGroup(ctx DirContext, proto parser.Proto, cfg *conf.
|
|||||||
"logicName": logicName,
|
"logicName": logicName,
|
||||||
"functions": functions,
|
"functions": functions,
|
||||||
"packageName": packageName,
|
"packageName": packageName,
|
||||||
"imports": strings.Join(imports.KeysStr(), pathx.NL),
|
"imports": strings.Join(imports.Keys(), pathx.NL),
|
||||||
}, filename, false); err != nil {
|
}, filename, false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ func (g *Generator) genServerGroup(ctx DirContext, proto parser.Proto, cfg *conf
|
|||||||
svcImport := fmt.Sprintf(`"%v"`, ctx.GetSvc().Package)
|
svcImport := fmt.Sprintf(`"%v"`, ctx.GetSvc().Package)
|
||||||
pbImport := fmt.Sprintf(`"%v"`, ctx.GetPb().Package)
|
pbImport := fmt.Sprintf(`"%v"`, ctx.GetPb().Package)
|
||||||
|
|
||||||
imports := collection.NewSet()
|
imports := collection.NewSet[string]()
|
||||||
imports.AddStr(logicImport, svcImport, pbImport)
|
imports.Add(logicImport, svcImport, pbImport)
|
||||||
|
|
||||||
head := util.GetHead(proto.Name)
|
head := util.GetHead(proto.Name)
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ func (g *Generator) genServerGroup(ctx DirContext, proto parser.Proto, cfg *conf
|
|||||||
"unimplementedServer": fmt.Sprintf("%s.Unimplemented%sServer", proto.PbPackage,
|
"unimplementedServer": fmt.Sprintf("%s.Unimplemented%sServer", proto.PbPackage,
|
||||||
parser.CamelCase(service.Name)),
|
parser.CamelCase(service.Name)),
|
||||||
"server": stringx.From(service.Name).ToCamel(),
|
"server": stringx.From(service.Name).ToCamel(),
|
||||||
"imports": strings.Join(imports.KeysStr(), pathx.NL),
|
"imports": strings.Join(imports.Keys(), pathx.NL),
|
||||||
"funcs": strings.Join(funcList, pathx.NL),
|
"funcs": strings.Join(funcList, pathx.NL),
|
||||||
"notStream": notStream,
|
"notStream": notStream,
|
||||||
}, serverFile, true); err != nil {
|
}, serverFile, true); err != nil {
|
||||||
@@ -111,8 +111,8 @@ func (g *Generator) genServerInCompatibility(ctx DirContext, proto parser.Proto,
|
|||||||
svcImport := fmt.Sprintf(`"%v"`, ctx.GetSvc().Package)
|
svcImport := fmt.Sprintf(`"%v"`, ctx.GetSvc().Package)
|
||||||
pbImport := fmt.Sprintf(`"%v"`, ctx.GetPb().Package)
|
pbImport := fmt.Sprintf(`"%v"`, ctx.GetPb().Package)
|
||||||
|
|
||||||
imports := collection.NewSet()
|
imports := collection.NewSet[string]()
|
||||||
imports.AddStr(logicImport, svcImport, pbImport)
|
imports.Add(logicImport, svcImport, pbImport)
|
||||||
|
|
||||||
head := util.GetHead(proto.Name)
|
head := util.GetHead(proto.Name)
|
||||||
service := proto.Service[0]
|
service := proto.Service[0]
|
||||||
@@ -145,7 +145,7 @@ func (g *Generator) genServerInCompatibility(ctx DirContext, proto parser.Proto,
|
|||||||
"unimplementedServer": fmt.Sprintf("%s.Unimplemented%sServer", proto.PbPackage,
|
"unimplementedServer": fmt.Sprintf("%s.Unimplemented%sServer", proto.PbPackage,
|
||||||
parser.CamelCase(service.Name)),
|
parser.CamelCase(service.Name)),
|
||||||
"server": stringx.From(service.Name).ToCamel(),
|
"server": stringx.From(service.Name).ToCamel(),
|
||||||
"imports": strings.Join(imports.KeysStr(), pathx.NL),
|
"imports": strings.Join(imports.Keys(), pathx.NL),
|
||||||
"funcs": strings.Join(funcList, pathx.NL),
|
"funcs": strings.Join(funcList, pathx.NL),
|
||||||
"notStream": notStream,
|
"notStream": notStream,
|
||||||
}, serverFile, true)
|
}, serverFile, true)
|
||||||
|
|||||||
Reference in New Issue
Block a user