Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Help generating mocks for generics #667

Closed
btomasini opened this issue Jul 28, 2022 · 2 comments
Closed

Help generating mocks for generics #667

btomasini opened this issue Jul 28, 2022 · 2 comments

Comments

@btomasini
Copy link

I am trying to execute mockgen in source mode against some code which contains generics.

I the following error:

2022/07/27 17:19:21 Loading input failed: don't know how to mock method of type *ast.IndexListExpr
repository/repository.go:3: running "mockgen": exit status 1

My guess is that I need to use a fork which contains support for generics. As such, I have tried to replace gomock with the following branch in my go.mod:

replace (
        github.com/golang/mock => github.com/bradleygore/gomock v1.6.1-0.20220713191646-ac74355d2d11
        github.com/golang/mock/mockgen => github.com/bradleygore/gomock/mock/mockgen v1.6.1-0.20220713191646-ac74355d2d11
)

But mockgen still errors out. I think I may not be installing the right version of mockgen. My generate executes the following:

//go:generate go install github.com/golang/mock/mockgen@v1.6.0
//go:generate mockgen -source=client.go -destination=./mock_repository/mock_client.go

Any help would be appreciated. I am not sure if my problem is one of managing a forked go module properly or with mockgen itself.

Thank you.

@btomasini
Copy link
Author

I hope this is somehow resolved by #663

@codyoss
Copy link
Member

codyoss commented Aug 11, 2022

Some general generic use-cases have been resolved on HEAD but not released. Follow the milestone for progress towards the release.

@codyoss codyoss closed this as completed Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants