Merge pull request #335 from testwill/string

chore:  use xxx.String() instead of string(xxx.Bytes())
This commit is contained in:
Randall O'Reilly 2023-12-12 11:48:17 -08:00 committed by GitHub
commit a5b96e6096
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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())
}
}