January 2020
Intermediate to advanced
640 pages
16h 56m
English
In this section, we will be introducing gomock [4], a very popular mocking framework for Go that leverages reflection and code generation to automatically create mocks based on Go interface definitions.
The framework and its supporting tools can be installed by running the following commands:
$ go get github.com/golang/mock/gomock $ go install github.com/golang/mock/mockgen
The mockgen tool is responsible for analyzing either individual Go files or entire packages and generating mocks for all (or specific) interfaces that are defined within them. It supports two modes of operation: