Open atombender opened 4 months ago
I hit this when generating mocks for azure-sdk-for-go clients because they make heavy use of internal + type alias to export what's needed
I think reflect mode needs to be updated to use the new API added in Go 1.22: https://github.com/golang/go/issues/63223
oh, that's a good find! Yes detecting the alias, and having the info on which type is aliased will definitely allow to resolve this cleanly!
This appears to only affect reflect mode. Source mode works correctly. It may be that this bug exists because type aliases are not available through reflection. If that is the case, feel free to close.
Actual behavior
Consider these files:
The generated mock will look like this:
This is a real problem since the
things
package is internal, e.g.internal/things.go
, relative tofoo
, which is in an adjacent package. This means the compilation fails:Expected behavior
The generated mock should actually refer to the original type:
To Reproduce
Repository with full repro. Test with:
Additional Information