fix(golang): Check error of xml Encode (#3027)

This commit is contained in:
Michael Cristina 2019-05-30 11:50:34 -05:00 committed by William Cheng
parent 87adba9c4b
commit a2e84c348c
2 changed files with 2 additions and 2 deletions

View File

@ -376,7 +376,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
} else if jsonCheck.MatchString(contentType) { } else if jsonCheck.MatchString(contentType) {
err = json.NewEncoder(bodyBuf).Encode(body) err = json.NewEncoder(bodyBuf).Encode(body)
} else if xmlCheck.MatchString(contentType) { } else if xmlCheck.MatchString(contentType) {
xml.NewEncoder(bodyBuf).Encode(body) err = xml.NewEncoder(bodyBuf).Encode(body)
} }
if err != nil { if err != nil {

View File

@ -387,7 +387,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
} else if jsonCheck.MatchString(contentType) { } else if jsonCheck.MatchString(contentType) {
err = json.NewEncoder(bodyBuf).Encode(body) err = json.NewEncoder(bodyBuf).Encode(body)
} else if xmlCheck.MatchString(contentType) { } else if xmlCheck.MatchString(contentType) {
xml.NewEncoder(bodyBuf).Encode(body) err = xml.NewEncoder(bodyBuf).Encode(body)
} }
if err != nil { if err != nil {