chore: update go-zero version (#5093)

Signed-off-by: kevin <wanjunfeng@gmail.com>
This commit is contained in:
Kevin Wan
2025-08-17 17:00:15 +08:00
committed by GitHub
parent a5d42e20d5
commit a81d898408
16 changed files with 99 additions and 107 deletions

View File

@@ -226,8 +226,8 @@ func formatDuration(duration time.Duration) string {
}
func genRouteImports(parentPkg string, api *spec.ApiSpec) string {
importSet := collection.NewSet()
importSet.AddStr(fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, contextDir)))
importSet := collection.NewSet[string]()
importSet.Add(fmt.Sprintf("\"%s\"", pathx.JoinPackages(parentPkg, contextDir)))
for _, group := range api.Service.Groups {
for _, route := range group.Routes {
folder := route.GetAnnotation(groupProperty)
@@ -237,11 +237,11 @@ func genRouteImports(parentPkg string, api *spec.ApiSpec) string {
continue
}
}
importSet.AddStr(fmt.Sprintf("%s \"%s\"", toPrefix(folder),
importSet.Add(fmt.Sprintf("%s \"%s\"", toPrefix(folder),
pathx.JoinPackages(parentPkg, handlerDir, folder)))
}
}
imports := importSet.KeysStr()
imports := importSet.Keys()
sort.Strings(imports)
projectSection := strings.Join(imports, "\n\t")
depSection := fmt.Sprintf("\"%s/rest\"", vars.ProjectOpenSourceURL)

View File

@@ -59,7 +59,7 @@ func getTypeName(tp spec.Type) string {
func genTypesWithGroup(dir string, cfg *config.Config, api *spec.ApiSpec) error {
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 {
group := v.GetAnnotation(groupProperty)
@@ -75,37 +75,37 @@ func genTypesWithGroup(dir string, cfg *config.Config, api *spec.ApiSpec) error
responseTypeName := getTypeName(v.ResponseType)
requestTypeFileSet, ok := typesBelongToFiles[requestTypeName]
if !ok {
requestTypeFileSet = collection.NewSet()
requestTypeFileSet = collection.NewSet[string]()
}
if len(requestTypeName) > 0 {
requestTypeFileSet.AddStr(group)
requestTypeFileSet.Add(group)
typesBelongToFiles[requestTypeName] = requestTypeFileSet
}
responseTypeFileSet, ok := typesBelongToFiles[responseTypeName]
if !ok {
responseTypeFileSet = collection.NewSet()
responseTypeFileSet = collection.NewSet[string]()
}
if len(responseTypeName) > 0 {
responseTypeFileSet.AddStr(group)
responseTypeFileSet.Add(group)
typesBelongToFiles[responseTypeName] = responseTypeFileSet
}
}
}
typesInOneFile := make(map[string]*collection.Set)
typesInOneFile := make(map[string]*collection.Set[string])
for typeName, fileSet := range typesBelongToFiles {
count := fileSet.Count()
switch {
case count == 0: // it means there has no structure type or no request/response body
continue
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]
if !ok {
typeSet = collection.NewSet()
typeSet = collection.NewSet[string]()
}
typeSet.AddStr(typeName)
typeSet.Add(typeName)
typesInOneFile[groupName] = typeSet
default: // it means this type is used in multiple groups.
continue
@@ -133,7 +133,7 @@ func genTypesWithGroup(dir string, cfg *config.Config, api *spec.ApiSpec) error
}
if typeCount == 1 { // belong to one group
groupName := groupSet.KeysStr()[0]
groupName := groupSet.Keys()[0]
types, ok := groupTypes[groupName]
if !ok {
types = make(map[string]spec.Type)

View File

@@ -115,29 +115,29 @@ func writeProperty(writer io.Writer, name, tag, comment string, tp spec.Type, in
}
func getAuths(api *spec.ApiSpec) []string {
authNames := collection.NewSet()
authNames := collection.NewSet[string]()
for _, g := range api.Service.Groups {
jwt := g.GetAnnotation("jwt")
if len(jwt) > 0 {
authNames.Add(jwt)
}
}
return authNames.KeysStr()
return authNames.Keys()
}
func getJwtTrans(api *spec.ApiSpec) []string {
jwtTransList := collection.NewSet()
jwtTransList := collection.NewSet[string]()
for _, g := range api.Service.Groups {
jt := g.GetAnnotation(jwtTransKey)
if len(jt) > 0 {
jwtTransList.Add(jt)
}
}
return jwtTransList.KeysStr()
return jwtTransList.Keys()
}
func getMiddleware(api *spec.ApiSpec) []string {
result := collection.NewSet()
result := collection.NewSet[string]()
for _, g := range api.Service.Groups {
middleware := g.GetAnnotation("middleware")
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 {