Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bytes: articulate the doc to show results of Split() given various inputs #40490

Open
leventov opened this issue Jul 30, 2020 · 3 comments
Open
Labels
Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@leventov
Copy link

It would be nice if bytes.Split() documented whether it returns an empty slice as the first/last slice of subslices if the input starts with the separator sequence or ends with the separator sequence, and also what does bytes.Split() return given an empty input: empty slice or a slice containing a single element - an empty slice.

@odeke-em odeke-em changed the title bytes.Split(): improve the doc bytes: articulate the doc to show results of Split() given various inputs Jul 30, 2020
@odeke-em
Copy link
Member

Thank you for this report @leventov!

The doc for strings contains more information and covers all the requests cases except for the one in which the separator is the first or last element https://golang.org/pkg/strings/#Split
Screen Shot 2020-07-30 at 11 26 58 AM

Kindly pinging our articulator in chief @robpike.

@odeke-em odeke-em added this to the Backlog milestone Jul 30, 2020
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 30, 2020
@cagedmantis
Copy link
Contributor

/cc @bradfitz @ianlancetaylor

@ghost
Copy link

ghost commented Jul 1, 2023

its also vague on when an empty slice is returned. strings.Split explains it:

If both s and sep are empty, Split returns an empty slice.

https://godocs.io/strings#Split

bytes.Split has the same behavior, but its not documented:

https://godocs.io/bytes#Split

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants