slices.BinarySearchFunc could be better

While debugging a function based upon “slices.BinarySearchFunc” I found that after finding a correct number, it is making 1 extra comparison (with the same inputs), if a found value is below the middle of a list.
If found value is closer to the end, it is doing 2 extra not needed comparisons: one, returning ==, second with < and last one again with == inputs.

The current implementation doesn’t explicitly specify how to handle cases where multiple elements in the slice have the same value as the target element. It might return the index of the first or the last occurrence.

In my case there were no identical values.
The search was in the slice with structs with indexes: “0,2,4,6,8,10,12,14,16,18,20”

In case of searching #6, comparison function got slice values: 10, 4, 8, 6, 6
In case of searching #16, comparison function got slice values: 10, 16, 14, 16