0

I need to get reflect.Type of interface type parameter.

The following code does not work if T is an interface:

func Test[T any]()  {
    var t0 T
    ty := reflect.TypeOf(t0)
    println(ty.String())
}

OSubachev
  • 26
  • 2
  • You need to use `reflect.TypeOf(&t0).Elem()`, for reasoning see the marked duplicate. Try it on the [Go Playground](https://go.dev/play/p/IreZ9lEE1uj). – icza Mar 17 '23 at 08:52

0 Answers0