From db086d0d0e6cd3667ebae97b1a18c7270dbc12a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=85=E5=AD=90?= Date: Sun, 27 Jun 2021 09:46:36 +0800 Subject: [PATCH] fix cmd proto server (#1112) --- cmd/kratos/internal/proto/server/template.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/kratos/internal/proto/server/template.go b/cmd/kratos/internal/proto/server/template.go index 4d746fcea..343ef2893 100644 --- a/cmd/kratos/internal/proto/server/template.go +++ b/cmd/kratos/internal/proto/server/template.go @@ -28,7 +28,7 @@ func New{{ .Service }}Service() *{{ .Service }}Service { {{- $s1 := "google.protobuf.Empty" }} {{ range .Methods }} -func (s *{{ .Service }}Service) {{ .Name }}(ctx context.Context, req {{ if eq .Reply $s1 }}*emptypb.Empty{{ else }}*pb.{{ .Request }}{{ end }}) ({{ if eq .Reply $s1 }}*emptypb.Empty{{ else }}*pb.{{ .Reply }}{{ end }}, error) { +func (s *{{ .Service }}Service) {{ .Name }}(ctx context.Context, req {{ if eq .Request $s1 }}*emptypb.Empty{{ else }}*pb.{{ .Request }}{{ end }}) ({{ if eq .Reply $s1 }}*emptypb.Empty{{ else }}*pb.{{ .Reply }}{{ end }}, error) { return {{ if eq .Reply $s1 }}&emptypb.Empty{}{{ else }}&pb.{{ .Reply }}{}{{ end }}, nil } {{- end }} @@ -53,7 +53,7 @@ type Method struct { func (s *Service) execute() ([]byte, error) { buf := new(bytes.Buffer) for _, method := range s.Methods { - if method.Request == "google.protobuf.Empty" { + if method.Request == "google.protobuf.Empty" || method.Reply == "google.protobuf.Empty" { s.GoogleEmpty = true } }