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.

move the core logic of mockgen out of main package to make mockgen importable #609

Open
@sanposhiho

Description

@sanposhiho

Hi team.

What

It would be nice if the core logic of mockgen is placed in some package other than main. This makes mockgen importable.

main package should contain only CLI-related processes such as option parsing.

Why

Users can import mockgen features. (In Go, we cannot import main package.)

This allows users

  • to customize mockgen to meet their own requirements.
  • to generate mock files for gomock by their own tool.

...etc

For example, I am developing a tool, called gomockhandler, to manage mocks of gomock.
https://github.com/sanposhiho/gomockhandler

Users need to install mockgen to use gomockhandler and gomockhandler calls mockgen through exec.Command.
https://github.com/sanposhiho/gomockhandler/blob/master/internal/mockgen/sourcemode/runner.go#L68

However, unexpected behaviors may occur due to differences in mockgen behavior depending on which mockgen the user has installed.
Ideally, it would be nice to be able to generate mocks without using user-installed mockgen and we can achieve that if we can import mockgen.

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