From 9d6edc60a928c507a1df0fdc28fd9e52f1f0dc94 Mon Sep 17 00:00:00 2001 From: Rogee Date: Fri, 10 Jan 2025 16:00:17 +0800 Subject: [PATCH] fix: params order --- pkg/ast/route/route.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/ast/route/route.go b/pkg/ast/route/route.go index 396b705..9df4a26 100644 --- a/pkg/ast/route/route.go +++ b/pkg/ast/route/route.go @@ -150,6 +150,7 @@ func ParseFile(file string) []RouteDefinition { log.WithField("file", file).WithField("action", decl.Name.Name).WithField("path", path).WithField("method", method).Info("get router") // 拿参数列表去, 忽略 context.Context 参数 + orderBindParams := []ParamDefinition{} for _, param := range decl.Type.Params.List { // paramsType, ok := param.Type.(*ast.SelectorExpr) @@ -187,6 +188,8 @@ func ParseFile(file string) []RouteDefinition { } bindParams[i].Type = typ + + orderBindParams = append(orderBindParams, bindParams[i]) break } } @@ -198,7 +201,7 @@ func ParseFile(file string) []RouteDefinition { Method: strings.ToUpper(method), Name: decl.Name.Name, HasData: len(decl.Type.Results.List) > 1, - Params: bindParams, + Params: orderBindParams, }) }