Skip to content

Commit abd441f

Browse files
authored
No Empty Responses in Go SDK in future. (#3135)
## Changes <!-- Brief summary of your changes that is easy to understand --> This PR updates templates such that only legacyEmptyResponse and googleEmpty are not rendered. Otherwise, it assumes that the Go SDK will return a response. GoogleEmpty - a google well known proto that ensures that we will never add a field in it. LegactEmptyResponse - Responses that are empty and not rendered in the Go SDK because of legacy reasons. Rendering it will be a breaking change for the users as it changes the method signature. ## Why <!-- Why are these changes needed? Provide the context that the reviewer might be missing. For example, were there any decisions behind the change that are not reflected in the code itself? --> We have decided in the Go SDK that we will not omit the Response in the method signature if it is empty in the future. As it restricts adding new fields in the response. So, to remove this restriction, we need to return an object from the beginning. So, this PR updates the template to take into account. ## Tests <!-- How have you tested the changes? --> Generated CLI with zero diff. <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent 4432d62 commit abd441f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

.codegen/service.go.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ func new{{.PascalName}}() *cobra.Command {
305305
return err
306306
}
307307
if {{.CamelName}}SkipWait {
308-
{{if not .Response.IsEmpty -}}
308+
{{if not ( or .Response.IsGoogleEmpty .Response.IsLegacyEmptyResponse) -}}
309309
return cmdio.Render(ctx, wait.Response)
310310
{{- else -}}
311311
return nil
@@ -358,7 +358,7 @@ func new{{.PascalName}}() *cobra.Command {
358358
// end service {{.Name}}{{end}}
359359

360360
{{- define "method-call" -}}
361-
{{if not .Response.IsEmpty -}}
361+
{{if not ( or .Response.IsGoogleEmpty .Response.IsLegacyEmptyResponse) -}}
362362
response{{ if not .Pagination}}, err{{end}} :=
363363
{{- else -}}
364364
err =
@@ -376,7 +376,7 @@ func new{{.PascalName}}() *cobra.Command {
376376
return err
377377
}
378378
{{- end}}
379-
{{ if not .Response.IsEmpty -}}
379+
{{ if not ( or .Response.IsGoogleEmpty .Response.IsLegacyEmptyResponse) -}}
380380
{{- if .IsResponseByteStream -}}
381381
defer response.{{.ResponseBodyField.PascalName}}.Close()
382382
return cmdio.Render{{ if .Pagination}}Iterator{{end}}(ctx, response.{{.ResponseBodyField.PascalName}})

0 commit comments

Comments
 (0)