[gazelle rule]: https://github.com/bazelbuild/bazel-gazelle#bazel-rule [golang/mock]: https://github.com/golang/mock [core go rules]: /docs/go/core/rules.md # Extra rules This is a collection of helper rules. These are not core to building a go binary, but are supplied to make life a little easier. ## Contents - [gazelle](#gazelle) - [gomock](#gomock) ## Additional resources - [gazelle rule] - [golang/mock] - [core go rules] ------------------------------------------------------------------------ gazelle ------- This rule has moved. See [gazelle rule] in the Gazelle repository. ## gomock
gomock(name, out, library, source_importpath, source, interfaces, package, self_package, aux_files,
       mockgen_tool, imports, copyright_file, mock_names, kwargs)
Calls [mockgen](https://github.com/golang/mock) to generates a Go file containing mocks from the given library. If `source` is given, the mocks are generated in source mode; otherwise in reflective mode. **PARAMETERS** | Name | Description | Default Value | | :------------- | :------------- | :------------- | | name | the target name. | none | | out | the output Go file name. | none | | 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. | None | | 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. | "" | | source | a Go file in the given library. If this is given, gomock will call mockgen in source mode to mock all interfaces in the file. | None | | interfaces | a list of interfaces in the given library to be mocked in reflective mode. | [] | | 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. | "" | | 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. | "" | | aux_files | a map from source files to their package path. This only needed when source is provided. See [mockgen's -aux_files](https://github.com/golang/mock#flags) for more information. | {} | | mockgen_tool | the mockgen tool to run. | Label("//extras/gomock:mockgen") | | imports | dictionary of name-path pairs of explicit imports to use. See [mockgen's -imports](https://github.com/golang/mock#flags) for more information. | {} | | 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. | None | | 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. | {} | | kwargs |

-

| none |