上QQ阅读APP看书,第一时间看更新
If Go had generics
If Go had generics, we could have written a function signature like the following to replace strings with runes, and we would not have to rewrite the inner logic:
func Map(f func(v <string>) <bool>, vs [] <string>) []<bool>
However, Go does not have generics, so we can use empty interfaces and reflection to achieve the same result.