Reflection is a very powerful feature that allows meta-programming, the capability of an application to examine its own structure. It's very useful to analyze the types in an application at runtime, and it is used in many encoding packages such as JSON and XML.
What's reflection?
Type assertions
We briefly mentioned how type assertions work in Chapter 3, An Overview of Go. A type assertion is an operation that allows us to go from interface to concrete type and vice versa. It takes the following form:
# unsafe assertion
v := SomeVar.(SomeType)
# safe assertion
v, ok := SomeVar.(SomeType)
The first version is unsafe, and it assigns a value to a single variable.
Using assertion as an argument of a function...