Skip to content

Commit

Permalink
chore: use res.Body.Bytes() instead of []byte(res.Body.String()) (#922)
Browse files Browse the repository at this point in the history
  • Loading branch information
testwill authored Jul 10, 2023
1 parent d794ce3 commit bc59f5e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion proto/helloworld/v1/echo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func TestGreeterService_SayHello_0(t *testing.T) {
router.ServeHTTP(res, tt.args.createReq())

var body bytes.Buffer
err := json.Compact(&body, []byte(res.Body.String()))
err := json.Compact(&body, res.Body.Bytes())
// 如果Compact失败,则说明不是json格式
if err != nil {
body.WriteString(res.Body.String())
Expand Down
2 changes: 1 addition & 1 deletion proto/helloworld/v1/gin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func TestGinGreeterService_SayHello_0(t *testing.T) {
router.ServeHTTP(res, tt.args.createReq())

var body bytes.Buffer
err := json.Compact(&body, []byte(res.Body.String()))
err := json.Compact(&body, res.Body.Bytes())
// 如果Compact失败,则说明不是json格式
if err != nil {
body.WriteString(res.Body.String())
Expand Down

0 comments on commit bc59f5e

Please sign in to comment.