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

Support variadic methods #68

Closed
adamcrume opened this issue Mar 17, 2017 · 2 comments
Closed

Support variadic methods #68

adamcrume opened this issue Mar 17, 2017 · 2 comments

Comments

@adamcrume
Copy link

I have a method with a printf-like signature: func(string, ...interface{}). When this is mocked and set up with myMock.EXPECT().myFunc(gomock.Any()), then the function is actually called, Call.call panics because len(args) < ft.NumIn(). This is because the generated mock code builds args by flattening the variadic arguments and normal arguments into a single slice, but the reflection API expects the variadic arguments to be wrapped up in a slice.

@jonbonazza
Copy link

I have a similar issue where I have a variadic signature:
func(context.Context, string, ...string)
and in one particular usage, I call it without providing any variadic args. I setup my expect call like:
mock.EXPECT().myFunc(gomock.Any(), gomock.Any())
but I get the error, "no matching expected call: ..." when it goes to execute the mocked function.

Any idea what the problem is with this?

@george-ring
Copy link

Running into this as well and would be interested in any workarounds.

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

3 participants