From 33208e6ef6ba5e7a29340bc2081bbc219fe083f5 Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 27 Aug 2020 13:49:31 +0800 Subject: [PATCH] return zero value instead of nil on generated logic --- tools/goctl/api/gogen/genlogic.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/goctl/api/gogen/genlogic.go b/tools/goctl/api/gogen/genlogic.go index 8182606d..c8c62e87 100644 --- a/tools/goctl/api/gogen/genlogic.go +++ b/tools/goctl/api/gogen/genlogic.go @@ -76,8 +76,9 @@ func genLogicByRoute(dir string, group spec.Group, route spec.Route) error { returnString := "" requestString := "" if len(route.ResponseType.Name) > 0 { - responseString = "(*types." + strings.Title(route.ResponseType.Name) + ", error)" - returnString = "return nil, nil" + resp := strings.Title(route.ResponseType.Name) + responseString = "(*types." + resp + ", error)" + returnString = fmt.Sprintf("return &types.%s{}, nil", resp) } else { responseString = "error" returnString = "return nil"