Mockgen can't handle anonymous struct type
Author: ChuntaoLuCreated Feb 16, 2018Updated Mar 9, 2023
Labelshelp wantedtype: feature request
Mockgen can't generate mocks for interfaces whose method param or return types are unnamed non-empty structs. For example:
Suppose I have a foo.go file whose package import path is foo:
package foo
type Client interface {
Get() struct{ x int }
}Running source mode mockgen -source=foo/foo.go gives
failed parsing returns: foo/foo.go:4:8: can't handle non-empty unnamed struct typesRunning reflect mode mockgen foo Client gives
Reflection: can't yet turn struct { x int } (struct) into a model.TypeSource: golang/mock