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:
// In foo/foo.go
package foo
import "github.com/atombender/gomock-issue/foo/internal/things"
type Thing = things.Thing
// In foo/internal/things/things.go
package things
type Thing struct{}
// In bar/bar.go
package bar
import "github.com/atombender/gomock-issue/foo"
type Starter interface {
Start(thing *foo.Thing)
}
This is a real problem since the things package is internal, e.g. internal/things.go, relative to foo, which is in an adjacent package. This means the compilation fails:
package github.com/atombender/gomock-issue/bar/mocks
bar/mocks/mocks.go:15:2: use of internal package github.com/atombender/gomock-issue/foo/internal/things not allowed
Expected behavior
The generated mock should actually refer to the original type:
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