It's not good Go code anyway. In Go you would use a for loop. Just because Go has generics nowadays doesn't mean you should abandon good taste and write ML/Haskell/Rust/C# in it.

Sure it's a bad example. But you can't simplify something like this without losing type safety:

    SortBy[T, K comparable](slice: []T, key: func (T) K)