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

Mockgen can't handle anonymous struct type #153

@ChuntaoLu

Description

@ChuntaoLu

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 types

Running reflect mode mockgen foo Client gives

Reflection: can't yet turn struct { x int } (struct) into a model.Type

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions