Let's imagine that we have an interface e.g. Fooer in the /internal/pkg/fooer directory.
We want to generate mocks for it. So we run minimock -i ./internal/pkg/fooer.Fooer -o internal/pkg/fooer to get a fooer_mock_test.go generated near the tests files.
In the generated file we have go:generate comment:
//go:generate minimock -i github.com/org/project/internal/pkg/fooer.Fooer -o ./internal/pkg/fooer/fooer_mock_test.go
Now we want to regenerate the code using go generate ./... in the project root, but it fails with:
minimock: stat internal/pkg/fooer: no such file or directory
fooer_mock_test.go:5: running "minimock": exit status 1
This is because the command in the go:generate comment should contains -o ./fooer_mock_test.go without the ./internal/pkg/fooer prefix so that the generated code is placed in the same directory that it is now.
Let's imagine that we have an interface e.g.
Fooer
in the/internal/pkg/fooer
directory. We want to generate mocks for it. So we runminimock -i ./internal/pkg/fooer.Fooer -o internal/pkg/fooer
to get afooer_mock_test.go
generated near the tests files.In the generated file we have
go:generate
comment://go:generate minimock -i github.com/org/project/internal/pkg/fooer.Fooer -o ./internal/pkg/fooer/fooer_mock_test.go
Now we want to regenerate the code using
go generate ./...
in the project root, but it fails with:This is because the command in the
go:generate
comment should contains-o ./fooer_mock_test.go
without the./internal/pkg/fooer
prefix so that the generated code is placed in the same directory that it is now.Is it a bug or am I doing something wrong?