]> Cypherpunks.ru repositories - gostls13.git/commitdiff
all: remove redundant string conversions when formatting []byte with %s
authorcui fliter <imcusg@gmail.com>
Sun, 20 Aug 2023 10:33:50 +0000 (18:33 +0800)
committerGopher Robot <gobot@golang.org>
Tue, 22 Aug 2023 22:52:37 +0000 (22:52 +0000)
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>

src/bytes/example_test.go
src/crypto/rsa/example_test.go
src/runtime/testdata/testprogcgo/numgoroutine.go

index 41a5e2e5bf64ccd11220aee53f23b76c5562e5ac..20faf3e1f5f6a32cedcbbb3767752afb40b0e15c 100644 (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
index d07ee7d18bbbef2aa28a4892041d31fcda53a795..d176743f2f479506dee7b37950f8673fba949ce3 100644 (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
index 1b9f202f46c827c5fa87d391921e46cf04915695..9cbb4e4b0d98bbeb8819792f2901e95b425277c5 100644 (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