golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.26k stars 608 forks source link

`go generate` fails after PR #78 #79

Closed korya closed 7 years ago

korya commented 7 years ago

Suddenly my build got broken. go generate started to fail with the following error message:

can't load package: package -o: cannot find package "-o" in any of:
    /usr/lib/go/src/-o (from $GOROOT)
    /godev/src/-o (from $GOPATH)
can't load package: package prog.bin: cannot find package "prog.bin" in any of:
    /usr/lib/go/src/prog.bin (from $GOROOT)
    /godev/src/prog.bin (from $GOPATH)
can't load package: package prog.go: cannot find package "prog.go" in any of:
    /usr/lib/go/src/prog.go (from $GOROOT)
    /godev/src/prog.go (from $GOPATH)

This is the failing go-generate line (it used to work fine):

//go:generate mockgen -package store -destination store-repo-mock_test.go github.com/PlanitarInc/walk-inside-api/service/userstore/repository Userstore
korya commented 7 years ago

I suspect the problem occurs only when buildFlags argument is not provided. Then buildFlags value is the empty string, and hence an additional empty argument is provided to go build command.

See https://github.com/golang/mock/pull/78/files#diff-8ba20c3ad6dcdd45830b043e21ba0358R76