]> Cypherpunks repositories - gostls13.git/commitdiff
bytes, strings: rename parameters in ExampleCut{Pre,Suf}fix
authorTobias Klauser <tklauser@distanz.ch>
Thu, 8 May 2025 12:13:16 +0000 (14:13 +0200)
committerGopher Robot <gobot@golang.org>
Mon, 12 May 2025 16:07:54 +0000 (09:07 -0700)
The old parameter name sep was probably copied from ExampleCut. Change
the parameter names to prefix and suffix, respectivly to make the
examples a bit more readable.

Change-Id: Ie14b0050c2fafe3301c5368efd548a1629a7545f
Reviewed-on: https://go-review.googlesource.com/c/go/+/670955
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Robert Griesemer <gri@google.com>
src/bytes/example_test.go
src/strings/example_test.go

index 71a4a9e2ca2f23fde18b2e8088e3b24e2fef42be..c489b950e59a913d794cd6f6d5568c21abe667c4 100644 (file)
@@ -245,9 +245,9 @@ func ExampleCut() {
 }
 
 func ExampleCutPrefix() {
-       show := func(s, sep string) {
-               after, found := bytes.CutPrefix([]byte(s), []byte(sep))
-               fmt.Printf("CutPrefix(%q, %q) = %q, %v\n", s, sep, after, found)
+       show := func(s, prefix string) {
+               after, found := bytes.CutPrefix([]byte(s), []byte(prefix))
+               fmt.Printf("CutPrefix(%q, %q) = %q, %v\n", s, prefix, after, found)
        }
        show("Gopher", "Go")
        show("Gopher", "ph")
@@ -257,9 +257,9 @@ func ExampleCutPrefix() {
 }
 
 func ExampleCutSuffix() {
-       show := func(s, sep string) {
-               before, found := bytes.CutSuffix([]byte(s), []byte(sep))
-               fmt.Printf("CutSuffix(%q, %q) = %q, %v\n", s, sep, before, found)
+       show := func(s, suffix string) {
+               before, found := bytes.CutSuffix([]byte(s), []byte(suffix))
+               fmt.Printf("CutSuffix(%q, %q) = %q, %v\n", s, suffix, before, found)
        }
        show("Gopher", "Go")
        show("Gopher", "er")
index da95d1e58e6499e994368c53c9aa28ff760c5be7..72adbae5f26a315f6111f3122e0faf2dc397c468 100644 (file)
@@ -116,9 +116,9 @@ func ExampleCut() {
 }
 
 func ExampleCutPrefix() {
-       show := func(s, sep string) {
-               after, found := strings.CutPrefix(s, sep)
-               fmt.Printf("CutPrefix(%q, %q) = %q, %v\n", s, sep, after, found)
+       show := func(s, prefix string) {
+               after, found := strings.CutPrefix(s, prefix)
+               fmt.Printf("CutPrefix(%q, %q) = %q, %v\n", s, prefix, after, found)
        }
        show("Gopher", "Go")
        show("Gopher", "ph")
@@ -128,9 +128,9 @@ func ExampleCutPrefix() {
 }
 
 func ExampleCutSuffix() {
-       show := func(s, sep string) {
-               before, found := strings.CutSuffix(s, sep)
-               fmt.Printf("CutSuffix(%q, %q) = %q, %v\n", s, sep, before, found)
+       show := func(s, suffix string) {
+               before, found := strings.CutSuffix(s, suffix)
+               fmt.Printf("CutSuffix(%q, %q) = %q, %v\n", s, suffix, before, found)
        }
        show("Gopher", "Go")
        show("Gopher", "er")