Reflection in Go

Reflection allows inspecting and manipulating variables at runtime using the reflect package.

  • Use reflect.TypeOf to get the type.
  • Use reflect.ValueOf to get the value.
  • Reflection is powerful but should be used sparingly for performance and clarity.
← PrevNext →