The stdlib

In the stdlib you can find some pkgs that could reduce their API’s immensely if and just if something like generics existed for Go, examples:

Contains 29 pkg funcs with names like AddT, CompareAndSwapT, where T could be Int32, Int64, Uint32, Uint64 and so on . . .

Almost literally the whole pkg API would be:

That just went from 29 functions with larger names to just 5 with shorter names.

Yep, this awesome concurrent map is coming! with interface{} everywhere . . .

In this case, the only benefit is type safety since the API is simple enough.

Very similar to the sync/atomic case, instead of Int, Intn, Int31, Int31n what about:

Same treatment goes for the rand.Rand type.

Maybe convert the Float, Int and Rat types into a general Number type and compute the operations depending on the generic.

And some others applicable cases are:

container/list

container/heap

container/ring

could be more, just haven’t done enough research

I also think that for example, let’s say we have this pretty common piece of code:

I believe if there were generics this kind of operations could be improved /optimized at compile time since the compiler knows what the format of the data looks like. Example below.

Same for all encoding/decoding stuff such as encoding/xml, encoding/csv is not included since all records are always returned in [][]string which means no reflection/type assertion at all.