Generic Parameter Type Assertion

Dynamic type assertion on generic parameter type is not possible at runtime, but there's a trick to do it by converting the value to any and do the normal type assertion. This means T.(type) is not possible, but any(T).(type) is possible:

func checkMe[T any](t T) {
switch any(t).(type) {
case []byte:
println("[]byte")
case string:
println("string")
default:
println("other")
}
}

Playground

Although this tricks work well, but it is considered as unsafe since checking type at runtime could be very error-prone.