Overview of Go generics
This section discusses Go generics, which is a forthcoming Go feature. Currently, generics and Go are under discussion by the Go community. However, one way or another, it is good to know how generics work, its philosophy, and what the generics discussions are about.
Go generics has been one of the most requested additions to the Go programming language. At the time of writing, it is said that generics is going to be part of Go 1.18.
The main idea behind generics in Go, as well as any other programming language that supports generics, is not having to write special code for supporting multiple data types when performing the same task.
Currently, Go supports multiple data types in functions such as fmt.Println()
using the empty interface and reflection—both interfaces and reflection are discussed in Chapter 4, Reflection and Interfaces.
However, demanding every programmer to write lots of code and implement lots...