...
1<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2
3
4 [gazelle rule]: https://github.com/bazelbuild/bazel-gazelle#bazel-rule
5 [golang/mock]: https://github.com/golang/mock
6 [core go rules]: /docs/go/core/rules.md
7
8# Extra rules
9
10This is a collection of helper rules. These are not core to building a go binary, but are supplied
11to make life a little easier.
12
13## Contents
14- [gazelle](#gazelle)
15- [gomock](#gomock)
16
17## Additional resources
18- [gazelle rule]
19- [golang/mock]
20- [core go rules]
21
22------------------------------------------------------------------------
23
24gazelle
25-------
26
27This rule has moved. See [gazelle rule] in the Gazelle repository.
28
29
30
31<a id="gomock"></a>
32
33## gomock
34
35<pre>
36gomock(<a href="#gomock-name">name</a>, <a href="#gomock-out">out</a>, <a href="#gomock-library">library</a>, <a href="#gomock-source_importpath">source_importpath</a>, <a href="#gomock-source">source</a>, <a href="#gomock-interfaces">interfaces</a>, <a href="#gomock-package">package</a>, <a href="#gomock-self_package">self_package</a>, <a href="#gomock-aux_files">aux_files</a>,
37 <a href="#gomock-mockgen_tool">mockgen_tool</a>, <a href="#gomock-imports">imports</a>, <a href="#gomock-copyright_file">copyright_file</a>, <a href="#gomock-mock_names">mock_names</a>, <a href="#gomock-kwargs">kwargs</a>)
38</pre>
39
40Calls [mockgen](https://github.com/golang/mock) to generates a Go file containing mocks from the given library.
41
42If `source` is given, the mocks are generated in source mode; otherwise in reflective mode.
43
44
45**PARAMETERS**
46
47
48| Name | Description | Default Value |
49| :------------- | :------------- | :------------- |
50| <a id="gomock-name"></a>name | the target name. | none |
51| <a id="gomock-out"></a>out | the output Go file name. | none |
52| <a id="gomock-library"></a>library | the Go library to look into for the interfaces (reflective mode) or source (source mode). If running in source mode, you can specify source_importpath instead of this parameter. | <code>None</code> |
53| <a id="gomock-source_importpath"></a>source_importpath | the importpath for the source file. Alternative to passing library, which can lead to circular dependencies between mock and library targets. Only valid for source mode. | <code>""</code> |
54| <a id="gomock-source"></a>source | a Go file in the given <code>library</code>. If this is given, <code>gomock</code> will call mockgen in source mode to mock all interfaces in the file. | <code>None</code> |
55| <a id="gomock-interfaces"></a>interfaces | a list of interfaces in the given <code>library</code> to be mocked in reflective mode. | <code>[]</code> |
56| <a id="gomock-package"></a>package | the name of the package the generated mocks should be in. If not specified, uses mockgen's default. See [mockgen's -package](https://github.com/golang/mock#flags) for more information. | <code>""</code> |
57| <a id="gomock-self_package"></a>self_package | the full package import path for the generated code. The purpose of this flag is to prevent import cycles in the generated code by trying to include its own package. See [mockgen's -self_package](https://github.com/golang/mock#flags) for more information. | <code>""</code> |
58| <a id="gomock-aux_files"></a>aux_files | a map from source files to their package path. This only needed when <code>source</code> is provided. See [mockgen's -aux_files](https://github.com/golang/mock#flags) for more information. | <code>{}</code> |
59| <a id="gomock-mockgen_tool"></a>mockgen_tool | the mockgen tool to run. | <code>Label("//extras/gomock:mockgen")</code> |
60| <a id="gomock-imports"></a>imports | dictionary of name-path pairs of explicit imports to use. See [mockgen's -imports](https://github.com/golang/mock#flags) for more information. | <code>{}</code> |
61| <a id="gomock-copyright_file"></a>copyright_file | optional file containing copyright to prepend to the generated contents. See [mockgen's -copyright_file](https://github.com/golang/mock#flags) for more information. | <code>None</code> |
62| <a id="gomock-mock_names"></a>mock_names | dictionary of interface name to mock name pairs to change the output names of the mock objects. Mock names default to 'Mock' prepended to the name of the interface. See [mockgen's -mock_names](https://github.com/golang/mock#flags) for more information. | <code>{}</code> |
63| <a id="gomock-kwargs"></a>kwargs | <p align="center"> - </p> | none |
64
65
View as plain text