Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Source mode fails with embedded interfaces #178

Closed
amatoenot opened this issue Apr 19, 2018 · 4 comments
Closed

Source mode fails with embedded interfaces #178

amatoenot opened this issue Apr 19, 2018 · 4 comments

Comments

@amatoenot
Copy link

amatoenot commented Apr 19, 2018

Here are my test files:

github.com/anyuser/test/test1.go:

package test

type A interface {
	Method1()
}

github.com/anyuser/test/test2.go:

package test

type B interface {
	A
}

Here's generation:

mockgen -source test2.go -destination test2_mocks.go -package test -aux_files test=test1.go

Error result:

Loading input failed: test2.go:4:2: unknown embedded interface A
@amatoenot
Copy link
Author

Previous closed same issue: #85

@balshetzer
Copy link
Collaborator

@amatoenot

Hi Sergey,

The command line for aux_files needs the full package name:

mockgen -source test2.go -destination test2_mocks.go -package test -aux_files=github.com/anyuser/test=test1.go

Also, you mentioned in #85 that you used reflect as a fallback. Please consider reflect mode as the first option to try and use source mode only if it can't work for some reason.

Finally, I opened #181 to look into eliminating the need for aux_files altogether.

@atthoriq
Copy link

Hi @balshetzer I encountered the same issue. Here are my files.

github.com/project/handler/init.go

package handler

type Handler interface {
	adminHandler
}

github.com/project/handler/admin.go

package handler

type adminHandler interface {
	Method()
}

Here's generation

mockgen -source init.go -package handler -aux_files=github.com/project/handler=admin.go  -destination mock_handler.go

Here's the output

Loading input failed: init.go:88:2: unknown embedded interface adminHandler

i don't know what's wrong with my command. can you help?

@codyoss
Copy link
Member

codyoss commented Jun 17, 2020

If you are having an issue please open a new issue, this one was closed over two years ago, thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants