]> Cypherpunks repositories - gostls13.git/commitdiff
bytes, strings: mention Cut in docs for Split and SplitN
authorIan Lance Taylor <iant@golang.org>
Thu, 3 Feb 2022 20:13:00 +0000 (12:13 -0800)
committerIan Lance Taylor <iant@golang.org>
Tue, 8 Feb 2022 22:25:54 +0000 (22:25 +0000)
For #46336

Change-Id: Idc23302085e14e24d571f5995d6d33ca964a0021
Reviewed-on: https://go-review.googlesource.com/c/go/+/382954
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/bytes/bytes.go
src/strings/strings.go

index 6fdaa49c7344921da2d1c987d714a61884935157..41323ad549bba92c5399dc071e8670de14053814 100644 (file)
@@ -372,6 +372,8 @@ func genSplit(s, sep []byte, sepSave, n int) [][]byte {
 //   n > 0: at most n subslices; the last subslice will be the unsplit remainder.
 //   n == 0: the result is nil (zero subslices)
 //   n < 0: all subslices
+//
+// To split around the first instance of a separator, see Cut.
 func SplitN(s, sep []byte, n int) [][]byte { return genSplit(s, sep, 0, n) }
 
 // SplitAfterN slices s into subslices after each instance of sep and
@@ -389,6 +391,8 @@ func SplitAfterN(s, sep []byte, n int) [][]byte {
 // the subslices between those separators.
 // If sep is empty, Split splits after each UTF-8 sequence.
 // It is equivalent to SplitN with a count of -1.
+//
+// To split around the first instance of a separator, see Cut.
 func Split(s, sep []byte) [][]byte { return genSplit(s, sep, 0, -1) }
 
 // SplitAfter slices s into all subslices after each instance of sep and
index c5a29e95f6dd5ac7602e9544fc1c8ffdc73bc865..5793d9e26f4ed86bf203379c44fecad8cb646cbf 100644 (file)
@@ -270,6 +270,8 @@ func genSplit(s, sep string, sepSave, n int) []string {
 //
 // Edge cases for s and sep (for example, empty strings) are handled
 // as described in the documentation for Split.
+//
+// To split around the first instance of a separator, see Cut.
 func SplitN(s, sep string, n int) []string { return genSplit(s, sep, 0, n) }
 
 // SplitAfterN slices s into substrings after each instance of sep and
@@ -296,6 +298,8 @@ func SplitAfterN(s, sep string, n int) []string {
 // and sep are empty, Split returns an empty slice.
 //
 // It is equivalent to SplitN with a count of -1.
+//
+// To split around the first instance of a separator, see Cut.
 func Split(s, sep string) []string { return genSplit(s, sep, 0, -1) }
 
 // SplitAfter slices s into all substrings after each instance of sep and