Skip to content

Instantly share code, notes, and snippets.

The Package reflect in the Go standard library implements run-time reflection, allowing a program to manipulate objects with arbitrary types.
We can build with the reflection package a kind of generic functionality. Because this package give us the possibility to determine the meta information of a function and it's input and output arguments while runtime.
Be careful when you start to use the reflection package it's hard to debug run time errors. For more information about reflection, I can recommend the following article about reflection.
See "The Laws of Reflection" for an introduction to reflection in Go: https://golang.org/doc/articles/laws_of_reflection.html
If you want see reflection in action below is a example: