Skip to content

Commit 5406328

Browse files
bytes, strings: mention Cut in docs for Split and SplitN
For #46336 Change-Id: Idc23302085e14e24d571f5995d6d33ca964a0021 Reviewed-on: https://go-review.googlesource.com/c/go/+/382954 Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Russ Cox <[email protected]>
1 parent 3e514a0 commit 5406328

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/bytes/bytes.go

+4
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ func genSplit(s, sep []byte, sepSave, n int) [][]byte {
372372
// n > 0: at most n subslices; the last subslice will be the unsplit remainder.
373373
// n == 0: the result is nil (zero subslices)
374374
// n < 0: all subslices
375+
//
376+
// To split around the first instance of a separator, see Cut.
375377
func SplitN(s, sep []byte, n int) [][]byte { return genSplit(s, sep, 0, n) }
376378

377379
// SplitAfterN slices s into subslices after each instance of sep and
@@ -389,6 +391,8 @@ func SplitAfterN(s, sep []byte, n int) [][]byte {
389391
// the subslices between those separators.
390392
// If sep is empty, Split splits after each UTF-8 sequence.
391393
// It is equivalent to SplitN with a count of -1.
394+
//
395+
// To split around the first instance of a separator, see Cut.
392396
func Split(s, sep []byte) [][]byte { return genSplit(s, sep, 0, -1) }
393397

394398
// SplitAfter slices s into all subslices after each instance of sep and

src/strings/strings.go

+4
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ func genSplit(s, sep string, sepSave, n int) []string {
270270
//
271271
// Edge cases for s and sep (for example, empty strings) are handled
272272
// as described in the documentation for Split.
273+
//
274+
// To split around the first instance of a separator, see Cut.
273275
func SplitN(s, sep string, n int) []string { return genSplit(s, sep, 0, n) }
274276

275277
// SplitAfterN slices s into substrings after each instance of sep and
@@ -296,6 +298,8 @@ func SplitAfterN(s, sep string, n int) []string {
296298
// and sep are empty, Split returns an empty slice.
297299
//
298300
// It is equivalent to SplitN with a count of -1.
301+
//
302+
// To split around the first instance of a separator, see Cut.
299303
func Split(s, sep string) []string { return genSplit(s, sep, 0, -1) }
300304

301305
// SplitAfter slices s into all substrings after each instance of sep and

0 commit comments

Comments
 (0)