matryer / moq

Interface mocking tool for go generate
http://bit.ly/meetmoq
MIT License
2k stars 127 forks source link

Since PR #105 target directory for mocks is no longer created #111

Closed breml closed 5 years ago

breml commented 5 years ago

@pdrum Thanks for your work on PR #105. I gave it a quick test and it looks like not all problems of #102 have been fixed.

I have setup the following test project:

$  tree
.
├── foo
│   └── realfoo
│       └── foo.go
└── interface.go

interface.go:

package foo

//go:generate moq -pkg mockfoo -out foo/mockfoo/foo.go . Fooer

type Fooer interface {
        Foo()
}

foo/realfoo/foo.go:

package foo

type Foo struct{}

func (f Foo) Foo() {}

If I then run go generate . in the root directory of this project, I get the following output:

$  go generate .
open foo/mockfoo/foo.go: no such file or directory
moq [flags] destination interface [interface2 [interface3 [...]]]
  -out string
        output file (default stdout)
  -pkg string
        package name (default will infer)
interface.go:3: running "moq": exit status 1

If I create the target directory for the mock with mkdir foo/mockfoo before I run moq or go generate, then it works as intended.

Bottom line is, moq now does no longer create any target directory for the mock (it does not make sure, that the target directory provided with -out <targetdir>/<targetfile> does exist.