From bc9d28b4d66285d82949a3cbdc08976741a3555d Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Wed, 19 Jul 2023 09:13:54 +0800 Subject: [PATCH] chore: use xxx.String() instead of string(xxx.Bytes()) --- bind/printer_test.go | 2 +- main_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bind/printer_test.go b/bind/printer_test.go index c533f39..5c53567 100644 --- a/bind/printer_test.go +++ b/bind/printer_test.go @@ -49,7 +49,7 @@ impl 1 impl 2 ` - str := string(out.Bytes()) + str := out.String() if !reflect.DeepEqual(str, want) { t.Fatalf("error:\nwant=%q\ngot =%q\n", want, str) } diff --git a/main_test.go b/main_test.go index 4f34797..c92bc3f 100644 --- a/main_test.go +++ b/main_test.go @@ -66,7 +66,7 @@ func TestGovet(t *testing.T) { cmd.Stderr = buf err := cmd.Run() if err != nil { - t.Fatalf("error running %s:\n%s\n%v", "go vet", string(buf.Bytes()), err) + t.Fatalf("error running %s:\n%s\n%v", "go vet", buf.String(), err) } } @@ -91,11 +91,11 @@ func TestGofmt(t *testing.T) { err = cmd.Run() if err != nil { - t.Fatalf("error running %s:\n%s\n%v", exe, string(buf.Bytes()), err) + t.Fatalf("error running %s:\n%s\n%v", exe, buf.String(), err) } if len(buf.Bytes()) != 0 { - t.Errorf("some files were not gofmt'ed:\n%s\n", string(buf.Bytes())) + t.Errorf("some files were not gofmt'ed:\n%s\n", buf.String()) } }