DEV Community

Takahiro Kudo
Takahiro Kudo

Posted on

1 2

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! πŸ˜†

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay