On Thu, 2025-02-20 at 09:57 -0800,
cpu...@gmail.com wrote:
> Sorry for not finding a better than this click bait subject.
>
> In
https://github.com/golang/go/issues/62642 this suggestion was
> made:
>
> slices.SortFunc(times, time.Time.Compare)
>
> It's totally unclear to me how Time.Compare matches the compare
> func(a,b T) int signature? I assume it's something from the golang
> spec, but which part?
In
https://go.dev/ref/spec#Method_expressions
Function values derived from methods are called with function call
syntax; the receiver is provided as the first argument to the call.
That is, given f := T.Mv, f is invoked as f(t, 7) not t.f(7).
So
https://pkg.go.dev/time#Time.Compare, func (t Time) Compare(u Time)
int, becomes time.Time.Compare(t, u Time) int.