golang / mock

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

How to write the mock result to a file in reflect mode #684

Open someview opened 1 year ago

someview commented 1 year ago

Actual behavior A clear and concise description of what the bug is.

Expected behavior A clear and concise description of what you expected to happen.

To Reproduce Steps to reproduce the behavior

  1. ...
  2. ...

Additional Information

Triage Notes for the Maintainers

someview commented 1 year ago

gomock mode (reflect or source): //go:generate mockgen . DecPooler type DecPooler interface { Pooler FreeToChan(msg dto.DecMsg) //ε½’θΏ˜ζΆˆζ―εˆ°ζ± ε­δΈ­ AllocFromChan() dto.DecMsg //δ»Žζ± ε­δΈ­εˆ†ι…ζΆˆζ― } Is there any way to write the mock result to a file in reflect mode

geoah commented 1 year ago

Was looking for this as well, can't do something like > out.go in go:generate and -destination doesn't seem to be supported in reflect mode.

m-shev commented 1 year ago

For writing the mock result to a file put the destination flag in the first place, like this

//go:generate mockgen -destination mock/resquest_test.go -package ${GOPACKAGE} some/package Request

package and interfaces always should be last