Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate mock for external library #172

Closed
alexisvisco opened this issue Mar 29, 2022 · 2 comments
Closed

Generate mock for external library #172

alexisvisco opened this issue Mar 29, 2022 · 2 comments

Comments

@alexisvisco
Copy link

Hi, I am wondering if it's possible to generates mock for external library, if it's possible how to do it ?

@breml
Copy link
Contributor

breml commented Mar 29, 2022

In some cases, I used type aliases for this use case like this:

package myreader

import "io"

//go:generate moq -out reader_mock.go . Reader

type Reader = io.Reader

@matryer
Copy link
Owner

matryer commented Mar 31, 2022

thanks @breml - another option is to copy the interface into your own project. This isn't a hack per se, some people like to do this anyway as it allows them to provide multiple implementations of something in their project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants