diff --git a/client.go.tmpl b/client.go.tmpl index 2b707b3..c11b9a1 100644 --- a/client.go.tmpl +++ b/client.go.tmpl @@ -60,14 +60,12 @@ func (c *{{$serviceNameClient}}) {{$method.Name}}(ctx context.Context{{range $_, {{- end }} resp, err := doHTTPRequest(ctx, c.client, c.urls[{{$i}}], {{$inputVar}}, {{$outputVar}}) - defer func() { - if resp != nil { - cerr := resp.Body.Close() - if err == nil && cerr != nil { - err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) - } + if resp != nil { + cerr := resp.Body.Close() + if err == nil && cerr != nil { + err = ErrWebrpcRequestFailed.WithCause(fmt.Errorf("failed to close response body: %w", cerr)) } - }() + } return {{range $i, $output := $method.Outputs}}out.Ret{{$i}}, {{end}}err } diff --git a/types.go.tmpl b/types.go.tmpl index 92937f7..94cfd22 100644 --- a/types.go.tmpl +++ b/types.go.tmpl @@ -78,7 +78,7 @@ func (w *{{firstLetterToLower $method.Name}}StreamWriter) Write({{range $i, $out {{ end }} {{- end }} -{{ end }} +{{- end }} {{- if $opts.streaming -}}