You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actual behavior
Given a method of an interface,
if one of the return values is of a type that comes from different package,
and if the name of one of the arguments conflicts with this package name,
then a compilation error happens.
Expected behavior
Such arg names should be sanitized - not only if they're empty ( or _), but also if they conflicts with such package name.
To Reproduce
Define interface
type Client interface {
// `file` is our package, that is defined outside of the interface's package
Upload(ctx context.Context, file *file.Handle) (*file.Header, error)
}
Then, when generating, this is what happens:
// Upload mocks base method.func (m*MockClient) Upload(ctx context.Context, file*file.Handle) (*file.Header, error) {
m.ctrl.T.Helper()
ret:=m.ctrl.Call(m, "Upload", ctx, file)
// compilation error: go treats `Header` as a property of the argument named file,// instead of a struct defined in the `file` packageret0, _:=ret[0].(*file.Header)
ret1, _:=ret[1].(error)
returnret0, ret1
}
Additional Information
I have already crafted a small PR with the following fix.
I will be happy to contribute if you guys find it useful.
Actual behavior
Given a method of an interface,
if one of the return values is of a type that comes from different package,
and if the name of one of the arguments conflicts with this package name,
then a compilation error happens.
Expected behavior
or
Such arg names should be sanitized - not only if they're empty (
_
), but also if they conflicts with such package name.To Reproduce
Define interface
Then, when generating, this is what happens:
Additional Information
I have already crafted a small PR with the following fix.
I will be happy to contribute if you guys find it useful.
fix getArgNames
reference to the current function
The text was updated successfully, but these errors were encountered: