chore: use xxx.String() instead of string(xxx.Bytes())

This commit is contained in:
guoguangwu 2023-07-19 09:13:54 +08:00
parent 744da80a3d
commit bc9d28b4d6
2 changed files with 4 additions and 4 deletions

View File

@ -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)
}

View File

@ -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())
}
}