Use reflect for building generic utilities like struct validators, ORM field mappers, and serializers when generics or interfaces are insufficient. Avoid reflection in hot paths due to performance cost.
Use for: serialization libraries, ORMs, dependency injection containers, test assertion helpers
Prefer generics (Go 1.18+) for type-safe containers and utility functions — generics are faster and safer
Prefer interfaces for runtime polymorphism — interfaces are idiomatic and compile-time safe
Reflection bypasses compile-time checks — panics at runtime for type mismatches
Benchmark before using in hot paths: reflect.ValueOf() allocates and is 10-100x slower than direct access