golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.3k stars 610 forks source link

can't generate mock with import tag versioning #379

Closed iDevoid closed 4 years ago

iDevoid commented 4 years ago

Actual behavior

mockgen -destination=mocks/mock_user.go -source=internal/module/user/initiator.go
2020/01/07 17:24:53 Loading input failed: internal/module/user/initiator.go:54:6: failed parsing arguments: internal/module/user/initiator.go:54:12: unknown package "atreugo"

Expected behavior it should generate the mock

To Reproduce Steps to reproduce the behavior

I am using "github.com/savsgio/atreugo/v10" for my http router with interface

type Handler interface {
    Test(ctx *atreugo.RequestCtx) error
    CreateNewAccount(ctx *atreugo.RequestCtx) error
}

it seems that gomock doesn't recognize the tag versioning, so it results as panic because there is no atreugo inside of my imports.

Additional Information

codyoss commented 4 years ago

Sounds like this could be a dupe of #326

codyoss commented 4 years ago

Going to close this one so we can keep discussion in one spot. There is a workaround for this. In your code you can alias your import: import atreugo "github.com/savsgio/atreugo/v10"