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

strings: Undocumented behavior of strings.FieldsFunc #12351

Closed
elwinar opened this issue Aug 26, 2015 · 2 comments
Closed

strings: Undocumented behavior of strings.FieldsFunc #12351

elwinar opened this issue Aug 26, 2015 · 2 comments

Comments

@elwinar
Copy link
Contributor

elwinar commented Aug 26, 2015

I just remarked by reading the source of the strings.FieldsFunc that the method will also remove empty fields from its return value. For example, see the following playground.

Seeing that the used algorithm isn't the same than the one for the splits, I wonder if it is an undocumented feature or a bug ?

@ianlancetaylor ianlancetaylor changed the title Undocumented behavior of strings.FieldsFunc strings: Undocumented behavior of strings.FieldsFunc Aug 27, 2015
@ianlancetaylor
Copy link
Contributor

The behaviour of FieldsFunc seems to match the documentation. It splits the string at each run of code points satisfying the function. This is different from the documentation of Split, which returns substrings separated by sep--not a run of sep, just sep. So I think this is working as intended.

I'm going to close this issue, but please feel free to reopen if you disagree.

@elwinar
Copy link
Contributor Author

elwinar commented Aug 27, 2015

Oh, I didn't saw the run part of the documentation. My bad.

@golang golang locked and limited conversation to collaborators Sep 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants