Parse Go packages with ease
*types.Alias(Go 1.23+gotypesalias=1) is resolved viatypes.Unalias. The alias name itself is not preserved (e.g.type UserID = stringis parsed asstring).*types.Signature(function types) falls back toAny{}.*types.TypeParam(generic type parameters) falls back toAny{}.- Generic type aliases (Go 1.24+, e.g.
type Vec[T any] = []T) are also handled viatypes.Unalias.
- Inputs containing
func(...)fields, generic type parameters, or type aliases used to panic withunsupported named type: *types.<Kind>. They now parse successfully and produceAny{}(or the resolved underlying type for aliases). If your downstream code relied on this panic for fail-fast validation, install a customReplacerthat explicitly rejects these kinds. - The panic message wording changed from
unsupported named type:tounsupported type:(the previous wording was misleading sinceMap,Slice, etc. are not named types).
- When a
*types.Aliasis encountered, the user-suppliedReplaceris invoked twice — once on the original alias type, then again on the Unalias-resolved type via the recursiveparseTypecall.Replacerimplementations should be idempotent.