You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

reflect.go 332 B

12345678910111213
  1. package reflect
  2. import "reflect"
  3. // GetGenericType 获得泛型的类型
  4. func GetGenericType[T any]() reflect.Type {
  5. return reflect.TypeOf([0]T{}).Elem()
  6. }
  7. // GetGenericElemType 获得泛型的类型。适用于数组、指针类型
  8. func GetGenericElemType[T any]() reflect.Type {
  9. return reflect.TypeOf([0]T{}).Elem().Elem()
  10. }

公共库

Contributors (1)