DEV Community

loading...

Go - Tips - generate gomock

takakd profile image Takahiro Kudo ・1 min read

I got the following error today, but I was able to generate it successfully after deleting the existing mock file.

% mockgen -source ./internal/app/usecase/xxx/repository.go -destination ./internal/app/usecase/xxx/repository_mock.go -package xxx
-: found packages xxx (repository.go) and mock_updateproteinevent (repository_mock.go) in /Users/xxx/go/src/proteinreminder/internal/app/usecase/xxx
2020/10/21 04:21:56 Loading input failed: loading package failed

# Delete
% rm -rf ./internal/app/usecase/xxx/repository_mock.go

# Run again and completed.
% mockgen -source ./internal/app/usecase/xxx/repository.go -destination ./internal/app/usecase/xxx/repository_mock.go -package xxx
Enter fullscreen mode Exit fullscreen mode

Discussion (2)

pic
Editor guide
Collapse
jacobsngoodwin profile image
Jacob Goodwin

I'll keep an eye on this. I just started learning to work with mocks myself!

Collapse
takakd profile image
Takahiro Kudo Author

Serendipity! 😆