| 1 |
.\" This file was pre-generated by help2man 1.47.1. |
| 2 |
.TH MOCKGEN "1" "September 2015" "" "User Commands" |
| 3 |
.SH NAME |
| 4 |
mockgen \- generate source for mock class of a Go source |
| 5 |
.SH DESCRIPTION |
| 6 |
The `mockgen` command is used to generate source code for a mock |
| 7 |
class given a Go source file containing interfaces to be mocked. |
| 8 |
|
| 9 |
mockgen has two modes of operation: source and reflect. |
| 10 |
.PP |
| 11 |
Source mode generates mock interfaces from a source file. |
| 12 |
It is enabled by using the \fB\-source\fR flag. Other flags that |
| 13 |
may be useful in this mode are \fB\-imports\fR and \fB\-aux_files\fR. |
| 14 |
Example: |
| 15 |
.IP |
| 16 |
mockgen \fB\-source\fR=\fI\,foo\/\fR.go [other options] |
| 17 |
.PP |
| 18 |
Reflect mode generates mock interfaces by building a program |
| 19 |
that uses reflection to understand interfaces. It is enabled |
| 20 |
by passing two non\-flag arguments: an import path, and a |
| 21 |
comma\-separated list of symbols. |
| 22 |
Example: |
| 23 |
.IP |
| 24 |
mockgen database/sql/driver Conn,Driver |
| 25 |
.HP |
| 26 |
\fB\-aux_files=\fR"": (source mode) Comma\-separated pkg=path pairs of auxiliary Go source files. |
| 27 |
.HP |
| 28 |
\fB\-debug_parser\fR=\fI\,false\/\fR: Print out parser results only. |
| 29 |
.HP |
| 30 |
\fB\-destination=\fR"": Output file; defaults to stdout. |
| 31 |
.HP |
| 32 |
\fB\-exec_only=\fR"": (reflect mode) If set, execute this reflection program. |
| 33 |
.HP |
| 34 |
\fB\-imports=\fR"": (source mode) Comma\-separated name=path pairs of explicit imports to use. |
| 35 |
.HP |
| 36 |
\fB\-package=\fR"": Package of the generated code; defaults to the package of the input with a 'mock_' prefix. |
| 37 |
.HP |
| 38 |
\fB\-prog_only\fR=\fI\,false\/\fR: (reflect mode) Only generate the reflection program; write it to stdout. |
| 39 |
.HP |
| 40 |
\fB\-self_package=\fR"": If set, the package this mock will be part of. |
| 41 |
.HP |
| 42 |
\fB\-source=\fR"": (source mode) Input Go source file; enables source mode. |
| 43 |
.PP |
| 44 |
mockgen has two modes of operation: source and reflect. |
| 45 |
.PP |
| 46 |
Source mode generates mock interfaces from a source file. |
| 47 |
It is enabled by using the \fB\-source\fR flag. Other flags that |
| 48 |
may be useful in this mode are \fB\-imports\fR and \fB\-aux_files\fR. |
| 49 |
Example: |
| 50 |
.IP |
| 51 |
mockgen \fB\-source\fR=\fI\,foo\/\fR.go [other options] |
| 52 |
.PP |
| 53 |
Reflect mode generates mock interfaces by building a program |
| 54 |
that uses reflection to understand interfaces. It is enabled |
| 55 |
by passing two non\-flag arguments: an import path, and a |
| 56 |
comma\-separated list of symbols. |
| 57 |
Example: |
| 58 |
.IP |
| 59 |
mockgen database/sql/driver Conn,Driver |
| 60 |
.HP |
| 61 |
\fB\-aux_files=\fR"": (source mode) Comma\-separated pkg=path pairs of auxiliary Go source files. |
| 62 |
.HP |
| 63 |
\fB\-debug_parser\fR=\fI\,false\/\fR: Print out parser results only. |
| 64 |
.HP |
| 65 |
\fB\-destination=\fR"": Output file; defaults to stdout. |
| 66 |
.HP |
| 67 |
\fB\-exec_only=\fR"": (reflect mode) If set, execute this reflection program. |
| 68 |
.HP |
| 69 |
\fB\-imports=\fR"": (source mode) Comma\-separated name=path pairs of explicit imports to use. |
| 70 |
.HP |
| 71 |
\fB\-package=\fR"": Package of the generated code; defaults to the package of the input with a 'mock_' prefix. |
| 72 |
.HP |
| 73 |
\fB\-prog_only\fR=\fI\,false\/\fR: (reflect mode) Only generate the reflection program; write it to stdout. |
| 74 |
.HP |
| 75 |
\fB\-self_package=\fR"": If set, the package this mock will be part of. |
| 76 |
.HP |
| 77 |
\fB\-source=\fR"": (source mode) Input Go source file; enables source mode. |