Generics in Golang
1
Mohit Kumar
2
Let’s sort integers
3
Let’s sort floats
4
Let’s sort a custom float64 type
5
How did we solve this prior to Generics?
6
Reflection
7
Let’s talk about it!!
8
Reflection
9
Reflection
10
Then why do we need Generics?
11
Issues with Reflection
12
Generics
13
Generics💪
14
Let’s break it down
15
Let’s see a real implementation
16
When to use generics?
17
When not to use generics?
18
When not to use generics?
19
One Thumb Rule
20
Avoid boilerplate
Corollary, don’t use type parameters prematurely; wait until you are about to write boilerplate code
21
Questions?