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 generates duplicate implementation for overlapping interfaces in source mode #497

@marten-seemann

Description

@marten-seemann

Actual behavior
Since Go 1.14 embedded interfaces can have overlapping methods, as the io.Closer in the following example:

type readCloser interface {
	io.Reader
	io.Closer
}

type writeCloser interface {
	io.Writer
	io.Closer
}

type ReadWriteCloser interface {
	readCloser
	writeCloser
}

When generating a mock for ReadWriteCloser, the mock implementation will declare Close() error twice. The mock therefore fails to compile: (*MockReadWriteCloser).Close redeclared in this block

Expected behavior
The overlapping method should only be implemented once.

To Reproduce Steps to reproduce the behavior

mockgen -source=xxx.go

Additional Information

  • gomock mode (reflect or source): reflect
  • gomock version or git ref: v1.4.4
  • golang version: 1.15.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions