Open
Description
I'm not sure if this has been discussed already (I couldn't find a prior issue), but currently reflect.Type
has no direct methods to retrieve the type arguments of generic types.
The only way to retrieve these type arguments is by parsing the string returned by Type.Name()
which includes fully qualified package names and could look something like this in a complex case: MyGenericType[some/package.Foo, map[string]other/package.Bar]
. This string is not easy to parse because of the possibility of nested type arguments, maps, slices, etc.
I propose adding methods to reflect.Type
to retrieve these type arguments programmatically:
NumTypeArg() int
TypeArg(i int) Type
Metadata
Metadata
Assignees
Type
Projects
Status