all: remove redundant string conversions when formatting []byte with %s
Change-Id: I603051a3174b139ffb81d20d42979c7f3f04a09a
Reviewed-on: https://go-review.googlesource.com/c/go/+/521136
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/src/bytes/example_test.go b/src/bytes/example_test.go
index 41a5e2e..20faf3e 100644
--- a/src/bytes/example_test.go
+++ b/src/bytes/example_test.go
@@ -81,9 +81,9 @@
var b bytes.Buffer
b.Grow(64)
b.Write([]byte("abcde"))
- fmt.Printf("%s\n", string(b.Next(2)))
- fmt.Printf("%s\n", string(b.Next(2)))
- fmt.Printf("%s", string(b.Next(2)))
+ fmt.Printf("%s\n", b.Next(2))
+ fmt.Printf("%s\n", b.Next(2))
+ fmt.Printf("%s", b.Next(2))
// Output:
// ab
// cd
diff --git a/src/crypto/rsa/example_test.go b/src/crypto/rsa/example_test.go
index d07ee7d..d176743 100644
--- a/src/crypto/rsa/example_test.go
+++ b/src/crypto/rsa/example_test.go
@@ -78,7 +78,7 @@
return
}
- fmt.Printf("Plaintext: %s\n", string(plaintext))
+ fmt.Printf("Plaintext: %s\n", plaintext)
}
func ExampleSignPKCS1v15() {
@@ -149,7 +149,7 @@
return
}
- fmt.Printf("Plaintext: %s\n", string(plaintext))
+ fmt.Printf("Plaintext: %s\n", plaintext)
// Remember that encryption only provides confidentiality. The
// ciphertext should be signed before authenticity is assumed and, even
diff --git a/src/runtime/testdata/testprogcgo/numgoroutine.go b/src/runtime/testdata/testprogcgo/numgoroutine.go
index 1b9f202..9cbb4e4 100644
--- a/src/runtime/testdata/testprogcgo/numgoroutine.go
+++ b/src/runtime/testdata/testprogcgo/numgoroutine.go
@@ -70,7 +70,7 @@
sbuf = sbuf[:runtime.Stack(sbuf, true)]
n = strings.Count(string(sbuf), "goroutine ")
if n != want {
- fmt.Printf("%s Stack: want %d; got %d:\n%s\n", label, want, n, string(sbuf))
+ fmt.Printf("%s Stack: want %d; got %d:\n%s\n", label, want, n, sbuf)
return "", false
}
return string(sbuf), true