matryer / moq

Interface mocking tool for go generate

Home Page:http://bit.ly/meetmoq

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generate mock for external library

alexisvisco opened this issue · comments

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

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

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.