Cannot use type assertion on type parameter value
tl;dr You can perform a type assertion only on interface values. So you must convert x to a valid interface type first, any / interface{} in this case: func isInt[T any](x T) (ok bool) { _, ok = any(x).(int) // convert, then assert return } So why does this fail to compile? _, ok = … Read more