2025-04-04 Why does Go's stdlib not have a map function? ======================================================== `Since 2022 Go has had generics `__, which is great. (Prior to that, `people perpetrated (ingenious) horrors with the Canadian Aboriginal Syllabics unicode block `__) But three years on, I was really surprised to find no `map function `__ in the stdlib. It's not particularly complex to implement, though I imagine there's a bunch of potential subtleties around optimisation etc.: .. code:: go func Map[FromType, ToType any](slice []FromType, f func(FromType) ToType) []ToType { var result = make([]ToType, len(slice)) for i, v := range slice { result[i] = f(v) } return result } Apparently everyone uses https://github.com/samber/lo ("A Lodash-style Go library"). I can understand wanting to be conservative about what goes in the stdlib, But ``map`` feels like one of the obvious initial additions to accompany new generics features, and the absence caught me out!