Skip to content

cannot generate mockfile for generic type #271

Description

@zhangjianxing

Actual behavior A clear and concise description of what the bug is.

# gogen.go
package src

//go:generate mockgen -source=gogen.go -destination=gogen_mock.go -package=src_test

type Base[M any] interface {
	Get() M
}

type MyInterface interface {
	Base[int]
}

type IntInterface = Base[int]

type MyInterface2 interface {
	IntInterface
}

Mockgen is able to generate MyInterface successfully, but not able to generate MyInterface2, and returns following bug

2025/07/28 10:05:40 Loading input failed: gogen.go:18:2: unknown embedded interface interview/src.IntInterface
gogen.go:3: running "mockgen": exit status 1

Expected behavior A clear and concise description of what you expected to
happen.

Mockgen should be able to generate MyInterface2 since the interface should be exactally same as MyInterface

To Reproduce Steps to reproduce the behavior

  1. run go generage ./...

Additional Information

  • gomock mode (reflect or source): source
  • gomock version or git ref: v0.5.2
  • golang version: 1.24.4

Triage Notes for the Maintainers

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions