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>
This commit is contained in:
cui fliter 2023-08-20 18:33:50 +08:00 committed by Gopher Robot
parent 291a32aa4b
commit 0163b3b32c
3 changed files with 6 additions and 6 deletions

View File

@ -81,9 +81,9 @@ func ExampleBuffer_Next() {
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

View File

@ -78,7 +78,7 @@ func ExampleDecryptPKCS1v15SessionKey() {
return
}
fmt.Printf("Plaintext: %s\n", string(plaintext))
fmt.Printf("Plaintext: %s\n", plaintext)
}
func ExampleSignPKCS1v15() {
@ -149,7 +149,7 @@ func ExampleDecryptOAEP() {
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

View File

@ -70,7 +70,7 @@ func checkNumGoroutine(label string, want int) (string, bool) {
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