Skip to content

Commit a2e84c3

Browse files
mcristina422wing328
authored andcommitted
fix(golang): Check error of xml Encode (#3027)
1 parent 87adba9 commit a2e84c3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

modules/openapi-generator/src/main/resources/go/client.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
376376
} else if jsonCheck.MatchString(contentType) {
377377
err = json.NewEncoder(bodyBuf).Encode(body)
378378
} else if xmlCheck.MatchString(contentType) {
379-
xml.NewEncoder(bodyBuf).Encode(body)
379+
err = xml.NewEncoder(bodyBuf).Encode(body)
380380
}
381381

382382
if err != nil {

samples/client/petstore/go/go-petstore/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
387387
} else if jsonCheck.MatchString(contentType) {
388388
err = json.NewEncoder(bodyBuf).Encode(body)
389389
} else if xmlCheck.MatchString(contentType) {
390-
xml.NewEncoder(bodyBuf).Encode(body)
390+
err = xml.NewEncoder(bodyBuf).Encode(body)
391391
}
392392

393393
if err != nil {

0 commit comments

Comments
 (0)