From 4caddb231f95671da81dd1326dd94277815a21f4 Mon Sep 17 00:00:00 2001 From: HeyJavaBean Date: Thu, 21 Nov 2024 14:38:22 +0800 Subject: [PATCH] fix: fix frugal slim template --- tool/internal_pkg/pluginmode/thriftgo/file_tpl.go | 14 ++++++++++++++ tool/internal_pkg/pluginmode/thriftgo/patcher.go | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tool/internal_pkg/pluginmode/thriftgo/file_tpl.go b/tool/internal_pkg/pluginmode/thriftgo/file_tpl.go index 8df91241dd..58d6baf77b 100644 --- a/tool/internal_pkg/pluginmode/thriftgo/file_tpl.go +++ b/tool/internal_pkg/pluginmode/thriftgo/file_tpl.go @@ -60,6 +60,7 @@ import ( const Body = ` {{define "body"}} +{{if GenerateFastAPIs}} {{- range .Scope.StructLikes}} {{template "StructLikeCodec" .}} {{- end}} @@ -67,6 +68,7 @@ const Body = ` {{- range .Scope.Services}} {{template "Processor" .}} {{- end}} +{{- end}}{{/* if GenerateFastAPIs */}} {{template "ArgsAndResult" .}} @@ -115,3 +117,15 @@ var basicTemplates = []string{ Body, RegisterHessian, } + +// SlimStructLikeDeepEqual +var SlimStructLikeDeepEqual = ` +{{define "StructLikeDeepEqual"}} +{{- end}}{{/* "StructLikeDeepEqual" */}} +` + +// SlimStructLikeDeepEqualField +var SlimStructLikeDeepEqualField = ` +{{define "StructLikeDeepEqualField"}} +{{- end}}{{/* "StructLikeDeepEqualField" */}} +` diff --git a/tool/internal_pkg/pluginmode/thriftgo/patcher.go b/tool/internal_pkg/pluginmode/thriftgo/patcher.go index 64d4b208a6..a82b4b6ed0 100644 --- a/tool/internal_pkg/pluginmode/thriftgo/patcher.go +++ b/tool/internal_pkg/pluginmode/thriftgo/patcher.go @@ -162,7 +162,10 @@ func (p *patcher) buildTemplates() (err error) { allTemplates = append(allTemplates, slim.StructLike, templates.StructLikeDefault, templates.FieldGetOrSet, - templates.FieldIsSet) + templates.FieldIsSet, + SlimStructLikeDeepEqual, + SlimStructLikeDeepEqualField, + ) } else { allTemplates = append(allTemplates, structLikeCodec, structLikeFastRead,