You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature request.
Implement strings.Includes([]string, string) bool and same thing for other types.
At least once a week we need to check that slice of strings includes another string.
It's common code that we have to implement in every project and every package.
The text was updated successfully, but these errors were encountered:
agnivade
changed the title
Feature request: implement Include function.
proposal: strings: implement Include function.
Sep 24, 2018
This should wait until a decision is made on generics. If the language ends up with generics, this function should work for all element types.
This is an extra API to avoid a four-line function. I'm not sure if it warrants being in the standard library. In comparison, most other APIs in the strings package are either more complex or fairly optimized.
At least once a week we need to check that slice of strings includes another string.
It's common code that we have to implement in every project and every package.
Can't you write a library and use it from those projects?
Also note that if the slice is large then that's not the best signature - better to use a map[string]bool instead of a []string.
In any event, this should be held for generics. This is an obvious thing we'd write in a 'slices' packages. (It's the canonical example of generic code, dating back to CLU.)
What version of Go are you using (
go version
)?go version go1.10.3 darwin/amd64
Feature request.
Implement
strings.Includes([]string, string) bool
and same thing for other types.At least once a week we need to check that slice of strings includes another string.
It's common code that we have to implement in every project and every package.
The text was updated successfully, but these errors were encountered: