bytes, strings: rename parameters in ExampleCut{Pre,Suf}fix

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>
This commit is contained in:
Tobias Klauser 2025-05-08 14:13:16 +02:00 committed by Gopher Robot
parent c0eb7ab306
commit 238d273da4
2 changed files with 12 additions and 12 deletions

View File

@ -245,9 +245,9 @@ func ExampleCut() {
} }
func ExampleCutPrefix() { func ExampleCutPrefix() {
show := func(s, sep string) { show := func(s, prefix string) {
after, found := bytes.CutPrefix([]byte(s), []byte(sep)) after, found := bytes.CutPrefix([]byte(s), []byte(prefix))
fmt.Printf("CutPrefix(%q, %q) = %q, %v\n", s, sep, after, found) fmt.Printf("CutPrefix(%q, %q) = %q, %v\n", s, prefix, after, found)
} }
show("Gopher", "Go") show("Gopher", "Go")
show("Gopher", "ph") show("Gopher", "ph")
@ -257,9 +257,9 @@ func ExampleCutPrefix() {
} }
func ExampleCutSuffix() { func ExampleCutSuffix() {
show := func(s, sep string) { show := func(s, suffix string) {
before, found := bytes.CutSuffix([]byte(s), []byte(sep)) before, found := bytes.CutSuffix([]byte(s), []byte(suffix))
fmt.Printf("CutSuffix(%q, %q) = %q, %v\n", s, sep, before, found) fmt.Printf("CutSuffix(%q, %q) = %q, %v\n", s, suffix, before, found)
} }
show("Gopher", "Go") show("Gopher", "Go")
show("Gopher", "er") show("Gopher", "er")

View File

@ -116,9 +116,9 @@ func ExampleCut() {
} }
func ExampleCutPrefix() { func ExampleCutPrefix() {
show := func(s, sep string) { show := func(s, prefix string) {
after, found := strings.CutPrefix(s, sep) after, found := strings.CutPrefix(s, prefix)
fmt.Printf("CutPrefix(%q, %q) = %q, %v\n", s, sep, after, found) fmt.Printf("CutPrefix(%q, %q) = %q, %v\n", s, prefix, after, found)
} }
show("Gopher", "Go") show("Gopher", "Go")
show("Gopher", "ph") show("Gopher", "ph")
@ -128,9 +128,9 @@ func ExampleCutPrefix() {
} }
func ExampleCutSuffix() { func ExampleCutSuffix() {
show := func(s, sep string) { show := func(s, suffix string) {
before, found := strings.CutSuffix(s, sep) before, found := strings.CutSuffix(s, suffix)
fmt.Printf("CutSuffix(%q, %q) = %q, %v\n", s, sep, before, found) fmt.Printf("CutSuffix(%q, %q) = %q, %v\n", s, suffix, before, found)
} }
show("Gopher", "Go") show("Gopher", "Go")
show("Gopher", "er") show("Gopher", "er")