Closed hoonmin closed 9 months ago
This is a proposal PR to generate mocks without error for following cases:
type Water[R any, C UnsignedInteger] interface { Fish(R) []C } type UnsignedInteger interface { ~uint | ~uint32 | ~uint64 }
Go types package seems to wrap interfaces that contain type constraints by checking a type set literal of the form ~T and A|B. https://github.com/golang/go/blob/master/src/go/types/decl.go#L668
types
~T
A|B
So gomock can just ignore that pattern to generate mocks safely without don't know how to mock method of type errors. I think this can be a better solution for custom type constraints than -exclude flag.
don't know how to mock method of type
-exclude
All committers have signed the CLA.
I think this change is good - just a couple comments. Thanks!
I learned some basic but important things from your review. I've applied all of your suggestions, thank you!
This is a proposal PR to generate mocks without error for following cases:
Go
types
package seems to wrap interfaces that contain type constraints by checking a type set literal of the form~T
andA|B
. https://github.com/golang/go/blob/master/src/go/types/decl.go#L668So gomock can just ignore that pattern to generate mocks safely without
don't know how to mock method of type
errors. I think this can be a better solution for custom type constraints than-exclude
flag.