That's not true. Here's their example written to be more generic:
func mapThingToThing(inSlice interface{}, mapperFn interface{}) []interface{} {
mapper := reflect.ValueOf(mapperFn)
input := reflect.ValueOf(inSlice)
output := make([]interface{}, input.Len())
for i := 0; i < input.Len(); i++ {
item := input.Index(i)
output[i] = mapper.Call([]reflect.Value{item})[0]
}
return output
}
and calling: fn := func(item string) string {
return item + "!"
}
res := mapThingToThing([]string{"a", "b", "c"}, fn)
for _, item := range res {
fmt.Printf("item = %+v\n", item)
}
I didn't say it was pretty or good, but it can be done. Really confused by the downvotes.