I'd argue indexing general slices is a pretty common need.
For example, right now I need to index `[]int` and `[]image.Point`.

To this end, I have submitted 
proposal https://github.com/golang/go/issues/76787 .

On Wednesday, December 10, 2025 at 10:46:16 PM UTC+8 [email protected] 
wrote:

> From consistency view, the name should really be slices.IndexElem.
>
> Maybe indexing subslices other than bytes and string is not common in 
> practice.
>
> On Wednesday, December 10, 2025 at 6:54:09 AM UTC+8 [email protected] 
> wrote:
>
>> Hi fellow Gophers
>>
>> I wonder why is the `Index` function from the "slices" package much less 
>> powerful than the one in the "bytes" package?
>>
>> `bytes.Index` allows us to search for {1, 2, 3} within {1, 1, 2, 3}, 
>> whereas `slices.Index` only does the trivial thing of whether a single 2 is 
>> inside {1, 1, 2, 3}.
>>
>> What is the best way of doing `bytes.Index` but on say integer slices 
>> `[]int`?
>> Is it reasonable to propose adding a function `slices.IndexAll` to the 
>> "slices" package?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/3fa96c9f-8189-4d76-8558-1e6def4843a9n%40googlegroups.com.

Reply via email to