0PricingLogin
Go Academy · Lesson

reflect.Type and reflect.Value

TypeOf, ValueOf, Kind, and Elem

reflect package overview

The reflect package allows Go programs to inspect types and values at runtime. It is the foundation of encoding libraries, ORMs, and dependency injection frameworks.

reflect.TypeOf

reflect.TypeOf(x) returns the reflect.Type of x's value:

t := reflect.TypeOf(42)
fmt.Println(t.Name())    // "int"
fmt.Println(t.Kind())    // "int"
fmt.Println(t.String())  // "int"

All lessons in this course

  1. reflect.Type and reflect.Value
  2. Inspecting Struct Fields and Tags
  3. Dynamic Function Calls
  4. Practical Reflection: Serializers
← Back to Go Academy