Fix typeName panic for interface type parameters
reflect.TypeOf on a nil interface value returns nil, causing a panic when Kind() is called. Use reflect.TypeFor[T]() instead, which resolves the type directly from the type parameter. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -69,8 +69,7 @@ func RunTyped[T any](
|
||||
}
|
||||
|
||||
func typeName[T any]() string {
|
||||
var zero T
|
||||
t := reflect.TypeOf(zero)
|
||||
t := reflect.TypeFor[T]()
|
||||
if t.Kind() == reflect.Pointer {
|
||||
t = t.Elem()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user