DEV Community

Takahiro Kudo
Takahiro Kudo

Posted on

Go - Tips - generate gomock

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

Top comments (2)

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

Serendipity! 😆