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

Additional resources


gazelle

This rule has moved. See gazelle rule in the Gazelle repository.

gomock

Calls mockgen 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

NameDescriptionDefault Value
namethe target name.none
librarythe Go library to took for the interfaces (reflecitve mode) or source (source mode).none
outthe output Go file name.none
sourcea 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
interfacesa list of interfaces in the given library to be mocked in reflective mode.[]
packagethe name of the package the generated mocks should be in. If not specified, uses mockgen's default. See mockgen's -package for more information.""
self_packagethe 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 for more information.""
aux_filesa map from source files to their package path. This only needed when source is provided. See mockgen's -aux_files for more information.{}
mockgen_toolthe mockgen tool to run.Label(“//extras/gomock:mockgen”)
importsdictionary of name-path pairs of explicit imports to use. See mockgen's -imports for more information.{}
copyright_fileoptional file containing copyright to prepend to the generated contents. See mockgen's -copyright_file for more information.None
mock_namesdictionary 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 for more information.{}
kwargs - none