-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
proposal: slices: add Trim, TrimRight, and TrimLeft #66672
Comments
While in general we want slices to follow bytes and strings, I think we've learned over the years that the use of "left" and "right" is parochial and confusing. We should use "begin" and "end" or something similar. |
While we are bike shedding, I feel the comments on the API suggest TrimLeading and TrimTrailing. |
the |
Changing the words "Left" and "Right" sounds fine to me, but I do have a preference for consistency with the "strings" and "bytes" package. Presumably we would introduce functions with the updated names there too? |
This comment was marked as duplicate.
This comment was marked as duplicate.
It's actually more like DropWhile because it stops filtering after the first false return and then just returns the rest, even if it passes the filter. I like slices.DeleteFunc because it takes the convoluted idiom for filtering a slice in place and makes it much simpler. If these return new slices, I'm not sure they meet the bar for simplifying complicated code you could just write some other way. |
Proposal Details
I propose the addition of:
These functions match similar functions found in the "bytes" and "strings" packages:
Trim
TrimLeft
TrimRight
TrimFunc
TrimLeftFunc
TrimRightFunc
The text was updated successfully, but these errors were encountered: