golang / mock

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

mockgen is importing an internal grpc package file #551

Closed sima-fastly closed 3 years ago

sima-fastly commented 3 years ago

mockgen is generating a mocked file with an google.golang.org/grpc/internal/status import which results in an “Use of internal package is not allowed” err

Expected behavior is to gen a file with google.golang.org/grpc/status import

this issue started happening when google.golang.org/protobuf was updated to 1.26.0 google.golang.org/grpc package was updated to 1.37.0 golang/mock was updated to 1.5.0

gomock mode is reflect go version go1.16.3 darwin/amd64

here is the mockgen cmd I am running //go:generate mockgen -destination mocks/audit_mock.go -package mocks ./provisioning/internal/audit Auditable

I tried using -imports flag to specify which non-internal files to be imported but the imports value is being ignored and I still see the /internal file is being imported

codyoss commented 3 years ago

Hey, thanks for the report. This looks like a duplicate of #244. To workaround this for now I would suggest using source mode. Closing.

sima-fastly commented 3 years ago

thanks for the note @codyoss we need to mockgen based on a set of go files as not all type defs are in one go file in our project. is there a way to source from a list of go files?

sima-fastly commented 3 years ago

we found a way to work around it by removing type refs thanks