matryer / moq

Interface mocking tool for go generate

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot create mock, getting "No packages found" error

svera opened this issue · comments

I'm trying to create mock for the following interface:

package vcs

type VCS interface {
...

Inside the interface dir (located at pkg/vcs/vcs.go) I run moq -out vcs_mock.go . VCS just to get the following error Couldn't load source package: No packages found. I've also tried using the go generator with the same results.

I'm using latest Go version (12.2) with the latest code in master (6cfb055).

yep, not work for vendored pkgs as well

it does not work at all with 1.12 with GOPATH even for not vendored pkgs

I ran into this same thing, and found that updating my copy of golang.org/x/tools/go/packages in $GOPATH and rebuilding moq resulted in a working build:

cd $GOPATH/src/github.com/matryer/moq
go get -u .
go install

I opened #101 to add a go.mod file, which should help avoid this sort of problem in the future.

@svera are you still able to reproduce the issue with the latest version of moq? Apologies for responding so late.

Closing as stale.