### Install mockgen Tool Source: https://pkg.go.dev/go.uber.org/mock Install the `mockgen` command-line tool using `go install`. Ensure your GOPATH/bin is in your PATH. ```bash go install go.uber.org/mock/mockgen@latest ``` ```bash mockgen -version ``` ```bash export PATH=$PATH:$(go env GOPATH)/bin ``` -------------------------------- ### Build Constraint Example Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/build_constraint This example demonstrates how to use build constraints to conditionally compile Go files. The file `example.go` will only be compiled if the build tag `example` is active. ```APIDOC ## Build Constraint Usage ### Description Build constraints allow you to conditionally compile Go source files. This is useful for including or excluding code based on the target operating system, architecture, or custom build tags. ### File Naming Convention Files intended to be compiled only under specific build tags should be named with the build tag followed by `.go`. For example, `example.go` will only be compiled if the build tag `example` is present. ### Example Consider a file named `example.go` with the following content: ```go //go:build example package main import "fmt" func main() { fmt.Println("This code is compiled only when the 'example' build tag is active.") } ``` To compile this file, you would use the `go build` command with the `-tags` flag: ```bash go build -tags=example ``` If you build without the `example` tag, this file will be ignored by the Go compiler. ``` -------------------------------- ### Eq Matcher Example Source: https://pkg.go.dev/go.uber.org/mock/gomock Returns a matcher that matches on equality. Use this for exact value comparisons. ```go Eq(5).Matches(5) // returns true Eq(5).Matches(4) // returns false ``` -------------------------------- ### Example Interface and Mock Implementation Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generated_identifier_conflict Demonstrates an interface with parameters that can cause conflicts and the corresponding generated mock method. ```APIDOC ## Interface Example ```go type Example interface { Method(_m, _mr, m, mr int) } ``` ### Description This interface defines a method `Method` with parameters that can lead to naming conflicts with generated mock receiver names. ## Mock Implementation for Example ```go // Method mocks base method func (_m *MockExample) Method(_m int, _mr int, m int, mr int) { _m.ctrl.Call(_m, "Method", _m, _mr, m, mr) } ``` ### Description This is the generated mock implementation for the `Method` function of the `Example` interface. It illustrates a potential conflict where the generated receiver name `_m` clashes with a parameter name `_m`. ``` -------------------------------- ### NewMockExample Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generated_identifier_conflict Creates a new mock instance for the Example interface. ```APIDOC ## NewMockExample ```go func NewMockExample(ctrl *gomock.Controller) *MockExample ``` ### Description This function constructs and returns a new mock object for the `Example` interface, which is controlled by the provided `gomock.Controller`. ``` -------------------------------- ### Standard Usage Example Source: https://pkg.go.dev/go.uber.org/mock/gomock Demonstrates the standard workflow for using gomock: defining an interface, generating a mock, and using the mock in a test. ```APIDOC ## Standard Usage 1. **Define an interface**: ```go type MyInterface interface { SomeMethod(x int64, y string) } ``` 2. **Generate a mock** using `mockgen`. 3. **Use the mock in a test**: ```go func TestMyThing(t *testing.T) { mockCtrl := gomock.NewController(t) mockObj := something.NewMockMyInterface(mockCtrl) mockObj.EXPECT().SomeMethod(4, "blah") // Pass mockObj to a real object and test its behavior. } ``` ``` -------------------------------- ### CallExample Function Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/unexported_method CallExample is a simple function that uses the Example interface. ```APIDOC ## func CallExample ### Description CallExample is a simple function that uses the interface ### Signature ```go func CallExample(e Example) ``` ``` -------------------------------- ### Get Mock Recorder Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/unexported_method Returns the mock recorder for the MockExample. This recorder is used to set up expectations on the mock's methods. ```go func (m *MockExample) EXPECT() *MockExampleMockRecorder ``` -------------------------------- ### Controller: Test Setup with NewController Source: https://pkg.go.dev/go.uber.org/mock/gomock Creates a new Controller for managing mock objects within a test. It's recommended to create a new Controller for each test. Passing *testing.T automatically registers cleanup. ```go func TestFoo(t *testing.T) { ctrl := gomock.NewController(t) // .. } ``` ```go func TestBar(t *testing.T) { t.Run("Sub-Test-1", st) { ctrl := gomock.NewController(st) // .. }) t.Run("Sub-Test-2", st) { ctrl := gomock.NewController(st) // .. }) }) ``` -------------------------------- ### AnyOf Matcher Example Source: https://pkg.go.dev/go.uber.org/mock/gomock Demonstrates the usage of the AnyOf Matcher, which returns true if at least one of the provided values matches. It can be used with other matchers like Nil() and Len(). ```go AnyOf(1, 2, 3).Matches(2) // returns true AnyOf(1, 2, 3).Matches(10) // returns false AnyOf(Nil(), Len(2)).Matches(nil) // returns true AnyOf(Nil(), Len(2)).Matches("hi") // returns true AnyOf(Nil(), Len(2)).Matches("hello") // returns false ``` -------------------------------- ### Example Function Usage Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/unexported_method A simple function that utilizes an interface. This function can be tested by passing a mock implementation of the interface. ```go func CallExample(e Example) ``` -------------------------------- ### MockExample.Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generated_identifier_conflict Mocks the base method 'Method' of the Example interface. ```APIDOC ## MockExample.Method ```go func (m_2 *MockExample) Method(_m, _mr, m, mr int) ``` ### Description This function is the mock implementation for the `Method` function defined in the `Example` interface. It handles the invocation and tracking of calls to the `Method`. ``` -------------------------------- ### Standard gomock Usage Example Source: https://pkg.go.dev/go.uber.org/mock/gomock Illustrates the typical workflow for using gomock: defining an interface, generating a mock, and using it in a test function. This pattern is fundamental for setting up mocks in Go unit tests. ```go type MyInterface interface { SomeMethod(x int64, y string) } ``` ```go func TestMyThing(t *testing.T) { mockCtrl := gomock.NewController(t) mockObj := something.NewMockMyInterface(mockCtrl) mockObj.EXPECT().SomeMethod(4, "blah") // pass mockObj to a real object and play with it. } ``` -------------------------------- ### Create New Mock Instance Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/unexported_method Function to create a new mock instance for the Example interface. It requires a gomock.Controller to manage mock behavior and expectations. ```go func NewMockExample(ctrl *gomock.Controller) *MockExample ``` -------------------------------- ### MockExample Struct Definition Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generated_identifier_conflict This Go struct represents the mock implementation for the Example interface. ```go type MockExample struct { // contains filtered or unexported fields } ``` -------------------------------- ### Build Stub with DoAndReturn Source: https://pkg.go.dev/go.uber.org/mock Generate a mock implementation that executes custom logic when a method is called. This example uses DoAndReturn to specify a function to execute. ```go func TestFoo(t *testing.T) { ctrl := gomock.NewController(t) m := NewMockFoo(ctrl) // Does not make any assertions. Executes the anonymous functions and returns // its result when Bar is invoked with 99. m. EXPECT(). Bar(gomock.Eq(99)). DoAndReturn(func(_ int) int { time.Sleep(1*time.Second) return 101 }). AnyTimes() // Does not make any assertions. Returns 103 when Bar is invoked with 101. m. EXPECT(). Bar(gomock.Eq(101)). Return(103). AnyTimes() SUT(m) } ``` -------------------------------- ### MockExample.VarargMethod Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generated_identifier_conflict Mocks the base method 'VarargMethod' of the Example interface. ```APIDOC ## MockExample.VarargMethod ```go func (m *MockExample) VarargMethod(_s, _x, a, ret int, varargs ...int) ``` ### Description This function serves as the mock implementation for the `VarargMethod` of the `Example` interface, supporting variable number of arguments. ``` -------------------------------- ### Nil Matcher Example Source: https://pkg.go.dev/go.uber.org/mock/gomock Returns a matcher that matches if the received value is nil. Useful for checking nil pointers or interfaces. ```go var x *bytes.Buffer Nil().Matches(x) // returns true x = &bytes.Buffer{} Nil().Matches(x) // returns false ``` -------------------------------- ### Build Mock with Assertions Source: https://pkg.go.dev/go.uber.org/mock Generate a mock implementation and set expectations for method calls. This example uses EXPECT() to define an assertion for the Bar method. ```go func TestFoo(t *testing.T) { ctrl := gomock.NewController(t) m := NewMockFoo(ctrl) // Asserts that the first and only call to Bar() is passed 99. // Anything else will fail. m. EXPECT(). Bar(gomock.Eq(99)). Return(101) SUT(m) } ``` -------------------------------- ### Mock Method: One Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generics/source Mocks the 'One' method, which takes a string argument and returns a string. This is a simple, non-generic method example. ```go func (m *MockBar[T, R]) One(arg0 string) string ``` -------------------------------- ### Run Sample Package Tests Source: https://pkg.go.dev/go.uber.org/mock/sample Execute tests for the sample package using GoMock. Ensure you are in the correct directory. ```bash go test go.uber.org/mock/sample ``` -------------------------------- ### Mock Implementation for Parenthesized Parameter Type Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/parenthesized_parameter_type This Go code shows the generated mock implementation for the `Example` interface. It includes the mock struct, the constructor `NewMockExample`, the `EXPECT` method, and the mocked `ParenthesizedParameterType` method. ```go type MockExample struct { // contains filtered or unexported fields } ``` ```go func NewMockExample(ctrl *gomock.Controller) *MockExample ``` ```go func (m *MockExample) EXPECT() *MockExampleMockRecorder ``` ```go func (m *MockExample) ParenthesizedParameterType(param *int) ``` -------------------------------- ### Controller: Create with NewController Source: https://pkg.go.dev/go.uber.org/mock/gomock Returns a new Controller, optionally with additional configuration options. Passing *testing.T is the preferred way to ensure automatic cleanup. ```go func NewController(t TestReporter, opts ...ControllerOption) *Controller ``` -------------------------------- ### Food Interface Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/package_mode%40v0.6.0 Defines the Food interface, which includes a method for getting calories. ```APIDOC ## type Food ### Description Represents a food item with a calorie count. ### Methods - `Calories() int`: Returns the calorie count of the food. ``` -------------------------------- ### Driver Interface Definition Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/package_mode%40v0.6.0 Defines a generic Driver interface for operating a car, with methods for starting and driving. ```go type Driver[FuelType fuel.Fuel, CarType Car[FuelType]] interface { Wroom() error Drive(car CarType) } ``` -------------------------------- ### MockSolarSystem Methods Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generics%40v0.0.0-20251217210410-349aac660616/source Documentation for MockSolarSystem, including its constructor and EXPECT method for setting up mock behavior. ```APIDOC ## MockSolarSystem ### Description Represents a mocked solar system with a generic type parameter T constrained to ordered types. It provides a constructor and a method to access its mock recorder. ### Methods * **NewMockSolarSystem[T constraints.Ordered](ctrl *gomock.Controller) *MockSolarSystem[T]** Constructor for creating a new MockSolarSystem. * **EXPECT() *MockSolarSystemMockRecorder[T]** Returns the mock recorder for setting expectations on methods. ``` -------------------------------- ### NewMockMything Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/import_collision/p2/mocks Creates a new mock instance for the Mything interface. ```APIDOC ## func NewMockMything ### Description NewMockMything creates a new mock instance. ### Signature ```go func NewMockMything(ctrl *gomock.Controller) *MockMything ``` ``` -------------------------------- ### Package.Print Source: https://pkg.go.dev/go.uber.org/mock/mockgen/model Writes the package name and its imported packages to the provided writer. ```go func (pkg *Package) Print(w io.Writer) ``` -------------------------------- ### Not Matcher Example Source: https://pkg.go.dev/go.uber.org/mock/gomock Reverses the results of a given child matcher. Use this to assert that a value does not match a specific condition. ```go Not(Eq(5)).Matches(4) // returns true Not(Eq(5)).Matches(5) // returns false ``` -------------------------------- ### MockExample.ParenthesizedParameterType Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/parenthesized_parameter_type This function mocks the ParenthesizedParameterType method of the Example interface. It is used to define expected calls and their behavior during testing. ```APIDOC ## func (*MockExampleMockRecorder) ParenthesizedParameterType ### Description ParenthesizedParameterType indicates an expected call of ParenthesizedParameterType. ### Method *gomock.Call ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```go mr.ParenthesizedParameterType(param any) ``` ### Response #### Success Response (200) *gomock.Call #### Response Example ```go // Example of how to use the recorder call := mr.ParenthesizedParameterType(gomock.Any()) ``` -------------------------------- ### MockMatcher.String Method Source: https://pkg.go.dev/go.uber.org/mock/gomock/internal/mock_gomock String mocks the base method of the Matcher interface. It is used to get a string representation of the matcher. ```APIDOC ## Method: (*MockMatcher) String ### Signature ```go func (m *MockMatcher) String() string ``` ### Description String mocks the base method. This method is intended to be used within tests to define expectations for the String method of the mocked interface. ``` -------------------------------- ### MockDriver Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/package_mode/mock Documentation for the MockDriver, including how to create a new mock instance and how to use the EXPECT() method to set up expectations. ```APIDOC ## MockDriver ### Description MockDriver is a mock implementation for the Driver interface. ### Type Definition ```go type MockDriver[FuelType fuel.Fuel, CarType package_mode.Car[FuelType]] struct { // contains filtered or unexported fields } ``` ### Constructor ```go func NewMockDriver[FuelType fuel.Fuel, CarType package_mode.Car[FuelType]](ctrl *gomock.Controller) *MockDriver[FuelType, CarType] ``` Creates a new mock instance for the Driver interface. ### Methods #### EXPECT ```go func (m *MockDriver[FuelType, CarType]) EXPECT() *MockDriverMockRecorder[FuelType, CarType] ``` EXPECT returns an object that allows the caller to indicate expected use. #### Drive ```go func (m *MockDriver[FuelType, CarType]) Drive(car CarType) ``` Drive mocks the base method for the Drive function. #### Wroom ```go func (m *MockDriver[FuelType, CarType]) Wroom() error ``` Wroom mocks the base method for the Wroom function. ``` -------------------------------- ### InAnyOrder Matcher Example Source: https://pkg.go.dev/go.uber.org/mock/gomock Matches collections of the same elements, ignoring the order. Useful when the order of elements in a slice or array does not matter. ```go InAnyOrder([]int{1, 2, 3}).Matches([]int{1, 3, 2}) // returns true InAnyOrder([]int{1, 2, 3}).Matches([]int{1, 2}) // returns false ``` -------------------------------- ### PostServiceMockMockRecorder Create Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/mock_name/mocks Indicates an expected call to the Create method on PostServiceMock. It takes arguments that define the expected input parameters. ```go func (mr *PostServiceMockMockRecorder) Create(title, body, author any) *PostServiceMockCreateCall ``` -------------------------------- ### Mock Food Calories Call Configuration Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/package_mode/mock Configure the behavior of the Calories method on the mock Food. Use Do to provide a custom function, DoAndReturn for a function that returns a value, or Return to set a specific return value. ```go type MockFoodCaloriesCall struct { *gomock.Call } ``` ```go func (c *MockFoodCaloriesCall) Do(f func() int) *MockFoodCaloriesCall ``` ```go func (c *MockFoodCaloriesCall) DoAndReturn(f func() int) *MockFoodCaloriesCall ``` ```go func (c *MockFoodCaloriesCall) Return(arg0 int) *MockFoodCaloriesCall ``` -------------------------------- ### Enforcing Call Order with InOrder Source: https://pkg.go.dev/go.uber.org/mock/gomock Example demonstrating how to enforce a specific order of mock calls using the `gomock.InOrder` function. ```APIDOC ## Enforcing Call Order with InOrder ```go gomock.InOrder( mockObj.EXPECT().SomeMethod(1, "first"), mockObj.EXPECT().SomeMethod(2, "second"), mockObj.EXPECT().SomeMethod(3, "third"), ) ``` ``` -------------------------------- ### NewMockMything Constructor Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/import_collision/p2/mocks Creates a new mock instance for the MockMything interface. Requires a gomock.Controller to manage mock behavior. ```go func NewMockMything(ctrl *gomock.Controller) *MockMything ``` -------------------------------- ### Enforcing Call Order with Call.After Source: https://pkg.go.dev/go.uber.org/mock/gomock Example demonstrating how to enforce a specific order of mock calls using the `Call.After` method. ```APIDOC ## Enforcing Call Order with Call.After ```go firstCall := mockObj.EXPECT().SomeMethod(1, "first") secondCall := mockObj.EXPECT().SomeMethod(2, "second").After(firstCall) mockObj.EXPECT().SomeMethod(3, "third").After(secondCall) ``` ``` -------------------------------- ### Method.Print Source: https://pkg.go.dev/go.uber.org/mock/mockgen/model Writes the method name and its signature to the provided writer. ```go func (m *Method) Print(w io.Writer) ``` -------------------------------- ### Get MockMethods EXPECT Recorder Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/self_package The EXPECT method returns a recorder that allows specifying expected calls on the MockMethods instance. ```go func (m *MockMethods) EXPECT() *MockMethodsMockRecorder ``` -------------------------------- ### UserServiceMockMockRecorder Create Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/mock_name/mocks Indicates an expected call to the Create method on UserServiceMock. It takes arguments that define the expected input parameters for user creation. ```go func (mr *UserServiceMockMockRecorder) Create(name any) *UserServiceMockCreateCall ``` -------------------------------- ### UserServiceMock Create Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/mock_name/mocks Mocks the base Create method for the UserService. This allows defining expected calls and their corresponding return values for user creation. ```go func (m *UserServiceMock) Create(name string) (*user.User, error) ``` -------------------------------- ### HyundaiSolaris Type Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/package_mode/cars Represents a Hyundai Solaris vehicle. Provides methods to get the brand, fuel tank information, and refuel. ```APIDOC ## type HyundaiSolaris ### Description Represents a Hyundai Solaris vehicle. ### Methods #### Brand() Returns the brand of the car. #### FuelTank() Returns the fuel tank information for the car. #### Refuel(fuel.Gasoline, int) Refuels the car with a specified amount of gasoline. ``` -------------------------------- ### Greet Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/custom_package_name/client/v1 The Greet method takes a GreetInput struct and returns a greeting string. ```APIDOC ## func (c *Client) Greet(in GreetInput) string ### Description Greets the user by name. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **in** (GreetInput) - Required - The input for the greeting. - **Name** (string) - Required - The name to greet. ### Request Example ```json { "Name": "World" } ``` ### Response #### Success Response (200) - **string** - The greeting message. #### Response Example ```json "Hello, World!" ``` ``` -------------------------------- ### FordF150 Type Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/package_mode/cars Represents a Ford F-150 vehicle. Provides methods to get the brand, fuel tank information, and refuel. ```APIDOC ## type FordF150 ### Description Represents a Ford F-150 vehicle. ### Methods #### Brand() Returns the brand of the car. #### FuelTank() Returns the fuel tank information for the car. #### Refuel(fuel.Diesel, int) Refuels the car with a specified amount of diesel fuel. ``` -------------------------------- ### Get MockMatcher Recorder Source: https://pkg.go.dev/go.uber.org/mock/gomock/internal/mock_gomock Returns the mock recorder for MockMatcher. This object is used to set expectations on the mock's methods. ```go func (m *MockMatcher) EXPECT() *MockMatcherMockRecorder ``` -------------------------------- ### NewController Source: https://pkg.go.dev/go.uber.org/mock/gomock Creates a new Controller instance. It's the recommended way to initialize a Controller. Passing a *testing.T ensures that Controller.Finish() is automatically invoked upon test completion. ```APIDOC ## NewController ```go func NewController(t TestReporter, opts ...ControllerOption) *Controller ``` NewController returns a new Controller. It is the preferred way to create a Controller. Passing *testing.T registers cleanup function to automatically call Controller.Finish when the test and all its subtests complete. ``` -------------------------------- ### AssignableToTypeOf Matcher Example Source: https://pkg.go.dev/go.uber.org/mock/gomock Matches if the parameter to the mock function is assignable to the type of the parameter passed to AssignableToTypeOf. This is useful for type-based matching. ```go var s fmt.Stringer = &bytes.Buffer{} AssignableToTypeOf(s).Matches(time.Second) // returns true AssignableToTypeOf(s).Matches(99) // returns false var ctx = reflect.TypeOf((*context.Context)(nil)).Elem() AssignableToTypeOf(ctx).Matches(context.Background()) // returns true ``` -------------------------------- ### Car Interface Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/package_mode%40v0.6.0 Defines the Car interface, which is generic over the fuel type. It includes methods for getting the brand, fuel tank, and refueling. ```APIDOC ## type Car[FuelType fuel.Fuel] ### Description Represents a car that is generic over its fuel type. ### Methods - `Brand() string`: Returns the brand of the car. - `FuelTank() cars.FuelTank[FuelType]`: Returns the fuel tank of the car. - `Refuel(fuel FuelType, volume int) error`: Refuels the car with a specified amount of fuel. ``` -------------------------------- ### PostServiceMock Create Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/mock_name/mocks Mocks the base Create method for the PostService. This is used to define expected calls and their return values. ```go func (m *PostServiceMock) Create(title, body string, author *user.User) (*post.Post, error) ``` -------------------------------- ### Mocked Method Implementation Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generated_identifier_conflict This is the implementation of the Method on the MockExample, which is part of the generated mock code. ```go func (m_2 *MockExample) Method(_m, _mr, m, mr int) { } ``` -------------------------------- ### MockEarth EXPECT and Water Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generics%40v0.0.0-20251217210410-349aac660616/source Provides the EXPECT method for MockEarth to indicate expected usage and the Water method mock for testing. ```go func (m *MockEarth[R]) EXPECT() *MockEarthMockRecorder[R] ``` ```go func (m *MockEarth[R]) Water(arg0 R) []R ``` -------------------------------- ### Get MockMath Recorder Source: https://pkg.go.dev/go.uber.org/mock/sample/concurrent/mock EXPECT returns an object that allows the caller to indicate expected use of the MockMath. This is part of the GoMock framework for setting up expectations. ```go func (m *MockMath) EXPECT() *MockMathMockRecorder ``` -------------------------------- ### MockFoodMockRecorder Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/package_mode/mock Methods for setting up expected calls on a mock Food object. ```APIDOC ## Calories ### Description Calories indicates an expected call of Calories. ### Method Signature ```go func (mr *MockFoodMockRecorder) Calories() *MockFoodCaloriesCall ``` ``` -------------------------------- ### Mocking Bar Interface Methods Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generics/source These snippets show how to set up expectations for methods on a generic mock recorder. They are used to define expected calls to methods like Seven, Seventeen, Six, Sixteen, Ten, Thirteen, Three, and Twelve. ```go func (mr *MockBarMockRecorder[T, R]) Seven(arg0 any) *gomock.Call ``` ```go func (mr *MockBarMockRecorder[T, R]) Seventeen() *gomock.Call ``` ```go func (mr *MockBarMockRecorder[T, R]) Six(arg0 any) *gomock.Call ``` ```go func (mr *MockBarMockRecorder[T, R]) Sixteen() *gomock.Call ``` ```go func (mr *MockBarMockRecorder[T, R]) Ten(arg0 any) *gomock.Call ``` ```go func (mr *MockBarMockRecorder[T, R]) Thirteen() *gomock.Call ``` ```go func (mr *MockBarMockRecorder[T, R]) Three(arg0 any) *gomock.Call ``` ```go func (mr *MockBarMockRecorder[T, R]) Twelve() *gomock.Call ``` ```go func (mr *MockBarMockRecorder[T, R]) Two(arg0 any) *gomock.Call ``` -------------------------------- ### Cond Matcher Example Source: https://pkg.go.dev/go.uber.org/mock/gomock Returns a matcher that matches when a given function returns true after being passed the parameter to the mock function. Useful for matching on struct fields or dynamic logic. ```go Cond(func(x int){return x == 1}).Matches(1) // returns true Cond(func(x int){return x == 2}).Matches(1) // returns false ``` -------------------------------- ### Interface.Print Source: https://pkg.go.dev/go.uber.org/mock/mockgen/model Writes the interface name and its methods to the provided writer. ```go func (intf *Interface) Print(w io.Writer) ``` -------------------------------- ### MockInterface HelloWorld Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/build_flags/mock1 Mocks the base method HelloWorld for the Interface. This is called during tests to verify behavior. ```go func (m *MockInterface) HelloWorld() string ``` -------------------------------- ### NewMockQuxerConsumer Constructor Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/alias/mock Creates a new mock instance for the QuxerConsumer interface. ```go func NewMockQuxerConsumer(ctrl *gomock.Controller) *MockQuxerConsumer ``` -------------------------------- ### Create MockBazer Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/alias/mock Creates a new mock instance for the Bazer interface. ```go func NewMockBazer(ctrl *gomock.Controller) *MockBazer ``` -------------------------------- ### Mything Interface Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/import_collision/p2 The Mything interface defines a method DoThat which takes an integer and returns a type FooExported from an imported package. This example highlights a potential issue where a variable name might collide with an imported package name. ```APIDOC ## type Mything ### Description Defines an interface with a method that demonstrates handling import collisions. ### Type Definition ```go type Mything interface { // issue here, is that the variable has the same name as an imported package. DoThat(internalpackage int) internalpackage.FooExported } ``` ### Method Signature - **DoThat**(internalpackage int) internalpackage.FooExported ``` -------------------------------- ### MockSolarSystem Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generics/source Provides functionality to create and manage mock instances of the SolarSystem interface. ```APIDOC ## NewMockSolarSystem ### Description Creates a new mock instance for the SolarSystem interface. ### Signature ```go func NewMockSolarSystem[T constraints.Ordered](ctrl *gomock.Controller) *MockSolarSystem[T] ``` ### Parameters * `ctrl` (*gomock.Controller) - The gomock controller to use for mocking. ``` ```APIDOC ## MockSolarSystem.EXPECT ### Description Returns an object that allows the caller to indicate expected use of the MockSolarSystem. ### Signature ```go func (m *MockSolarSystem[T]) EXPECT() *MockSolarSystemMockRecorder[T] ``` ### Returns * `*MockSolarSystemMockRecorder[T]` - An object for setting expectations. ``` ```APIDOC ## MockSolarSystem.Water ### Description Mocks the base method for the Water operation. ### Signature ```go func (m *MockSolarSystem[T]) Water(arg0 T) []T ``` ### Parameters * `arg0` (T) - The input value of type T. ### Returns * `[]T` - A slice of values of type T. ``` -------------------------------- ### Format Got Value with Custom String Representation Source: https://pkg.go.dev/go.uber.org/mock Use GotFormatterAdapter and GotFormatterFunc to define a custom string format for the received value. This example formats integers with leading zeros, showing '03' instead of '3' if the received value is 3. ```go gomock.GotFormatterAdapter( gomock.GotFormatterFunc(func(i any) string { // Leading 0s return fmt.Sprintf("%02d", i) }), gomock.Eq(15), ) ``` -------------------------------- ### MockMilkyWay Methods Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generics%40v0.0.0-20251217210410-349aac660616/source Details the methods for MockMilkyWay, including its constructor and the Water method for operations related to a mocked solar system. ```APIDOC ## MockMilkyWay ### Description Represents a mocked Milky Way with a generic type parameter R constrained to integers. It includes methods for creating mock instances and performing operations like Water. ### Methods * **NewMockMilkyWay[R constraints.Integer](ctrl *gomock.Controller) *MockMilkyWay[R]** Constructor for creating a new MockMilkyWay. * **EXPECT() *MockMilkyWayMockRecorder[R]** Returns the mock recorder for setting expectations on methods. * **Water(arg0 R) []R** Executes the Water method on the mock, returning a slice of R. ``` -------------------------------- ### Mock Human Interface Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/package_mode/mock Defines a mock implementation of the Human interface. It includes a constructor and methods for mocking. ```go type MockHuman struct { // contains filtered or unexported fields } ``` ```go func NewMockHuman(ctrl *gomock.Controller) *MockHuman ``` ```go func (m *MockHuman) Breathe() ``` ```go func (m *MockHuman) EXPECT() *MockHumanMockRecorder ``` ```go func (m *MockHuman) Eat(foods ...package_mode.Food) ``` ```go func (m *MockHuman) Sleep(duration time.Duration) ``` -------------------------------- ### Successful Build After Patch Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/mock_in_test_package Illustrates the successful output of `go generate` and `go test` after applying a patch that correctly handles mock generation for `_test` suffixed packages. The tests pass without compilation errors. ```bash $ go generate $ go test ok github.com/golang/mock/mockgen/internal/tests/mock_in_test_package 0.031s ``` -------------------------------- ### MockMilkyWayMockRecorder Methods Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generics%40v0.0.0-20251217210410-349aac660616/source Lists the methods available on the MockMilkyWayMockRecorder, used for setting expectations on the Water method of a mocked MilkyWay. ```APIDOC ## MockMilkyWayMockRecorder ### Description Recorder for MockMilkyWay, used to set expectations on its methods. ### Methods * **Water(arg0 any) *gomock.Call** Records an expectation for the Water method. ``` -------------------------------- ### MockMything EXPECT Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/import_collision/p2/mocks Returns an object that allows the caller to indicate expected use of the MockMything mock. This is used for setting up test expectations. ```go func (m *MockMything) EXPECT() *MockMythingMockRecorder ``` -------------------------------- ### UserServiceMockMockRecorder.Create Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/mock_name/mocks Records an expected call to the Create method on UserServiceMock. ```APIDOC ## UserServiceMockMockRecorder.Create ### Description Records an expected call to the `Create` method on the `UserServiceMock`. This is used in conjunction with the mock recorder to set up expectations for method calls during testing. ### Method Signature ```go func (mr *UserServiceMockMockRecorder) Create(name any) *UserServiceMockCreateCall ``` ### Usage This method is called to indicate that the `Create` method is expected to be called. It takes the expected arguments (in this case, `name`) and returns a `*UserServiceMockCreateCall` object, which can then be used to configure the call's behavior (e.g., setting return values or custom logic). ``` -------------------------------- ### Define Foo Interface Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/add_generate_directive Defines the Foo interface with a Bar method that accepts a slice of strings and a channel for messages. This is the interface that will be mocked. ```go type Foo interface { Bar(channels []string, message chan<- Message) } ``` -------------------------------- ### Greet Method Signature Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/custom_package_name/client/v1 Signature for the Greet method on the Client struct. It takes GreetInput and returns a string. ```go func (c *Client) Greet(in GreetInput) string ``` -------------------------------- ### Create New MockMatcher Instance Source: https://pkg.go.dev/go.uber.org/mock/gomock/internal/mock_gomock Creates a new instance of MockMatcher. This function is used to initialize a mock object for testing purposes. ```go func NewMockMatcher(ctrl *gomock.Controller) *MockMatcher ``` -------------------------------- ### Mock Food Interface Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/package_mode/mock Defines a mock implementation of the Food interface. It includes a constructor and methods for mocking. ```go type MockFood struct { // contains filtered or unexported fields } ``` ```go func NewMockFood(ctrl *gomock.Controller) *MockFood ``` ```go func (m *MockFood) Calories() int ``` ```go func (m *MockFood) EXPECT() *MockFoodMockRecorder ``` -------------------------------- ### Create New MockMath Instance Source: https://pkg.go.dev/go.uber.org/mock/sample/concurrent/mock Function to create a new mock instance of MockMath. It requires a gomock.Controller to manage the mock's behavior. ```go func NewMockMath(ctrl *gomock.Controller) *MockMath ``` -------------------------------- ### Mock Method: Qux Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/const_array_length Mock implementation for the Qux method of the 'I' interface. It returns an array of size 3. ```go func (m *MockI) Qux() [3]int ``` -------------------------------- ### Controller: Create with Context Source: https://pkg.go.dev/go.uber.org/mock/gomock Returns a new Controller and a Context that is cancelled on any fatal failure. Useful for managing mock lifecycles tied to a specific context. ```go func WithContext(ctx context.Context, t TestReporter) (*Controller, context.Context) ``` -------------------------------- ### MockBar Methods Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generics/source Documentation for the methods available on the MockBar type. ```APIDOC ## MockBar Methods ### EXPECT #### Description EXPECT returns an object that allows the caller to indicate expected use. #### Signature ```go func (m *MockBar[T, R]) EXPECT() *MockBarMockRecorder[T, R] ``` ### One #### Description One mocks base method. #### Signature ```go func (m *MockBar[T, R]) One(arg0 string) string ``` ### Two #### Description Two mocks base method. #### Signature ```go func (m *MockBar[T, R]) Two(arg0 T) string ``` ### Three #### Description Three mocks base method. #### Signature ```go func (m *MockBar[T, R]) Three(arg0 T) R ``` ### Four #### Description Four mocks base method. #### Signature ```go func (m *MockBar[T, R]) Four(arg0 T) generics.Foo[T, R] ``` ### Five #### Description Five mocks base method. #### Signature ```go func (m *MockBar[T, R]) Five(arg0 T) generics.Baz[T] ``` ### Six #### Description Six mocks base method. #### Signature ```go func (m *MockBar[T, R]) Six(arg0 T) *generics.Baz[T] ``` ### Seven #### Description Seven mocks base method. #### Signature ```go func (m *MockBar[T, R]) Seven(arg0 T) other.One[T] ``` ### Eight #### Description Eight mocks base method. #### Signature ```go func (m *MockBar[T, R]) Eight(arg0 T) other.Two[T, R] ``` ### Nine #### Description Nine mocks base method. #### Signature ```go func (m *MockBar[T, R]) Nine(arg0 generics.Iface[T]) ``` ### Ten #### Description Ten mocks base method. #### Signature ```go func (m *MockBar[T, R]) Ten(arg0 *T) ``` ### Eleven #### Description Eleven mocks base method. #### Signature ```go func (m *MockBar[T, R]) Eleven() (*other.One[T], error) ``` ### Twelve #### Description Twelve mocks base method. #### Signature ```go func (m *MockBar[T, R]) Twelve() (*other.Two[T, R], error) ``` ### Thirteen #### Description Thirteen mocks base method. #### Signature ```go func (m *MockBar[T, R]) Thirteen() (generics.Baz[generics.StructType], error) ``` ### Fourteen #### Description Fourteen mocks base method. #### Signature ```go func (m *MockBar[T, R]) Fourteen() (*generics.Foo[generics.StructType, generics.StructType2], error) ``` ### Fifteen #### Description Fifteen mocks base method. #### Signature ```go func (m *MockBar[T, R]) Fifteen() (generics.Iface[generics.StructType], error) ``` ### Sixteen #### Description Sixteen mocks base method. #### Signature ```go func (m *MockBar[T, R]) Sixteen() (generics.Baz[other.Three], error) ``` ### Seventeen #### Description Seventeen mocks base method. #### Signature ```go func (m *MockBar[T, R]) Seventeen() (*generics.Foo[other.Three, other.Four], error) ``` ### Eighteen #### Description Eighteen mocks base method. #### Signature ```go func (m *MockBar[T, R]) Eighteen() (generics.Iface[*other.Five], error) ``` ### Nineteen #### Description Nineteen mocks base method. #### Signature ```go func (m *MockBar[T, R]) Nineteen() generics.AliasType ``` ``` -------------------------------- ### MockMilkyWayMockRecorder Methods Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generics/source Methods available on the MockMilkyWayMockRecorder for setting up expectations on calls to the MockMilkyWay. ```APIDOC ## MockMilkyWayMockRecorder[R constraints.Integer] ### Methods - **Water(arg0 any) *gomock.Call** ``` -------------------------------- ### Method Recorder for MockExample Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generated_identifier_conflict This method on MockExampleMockRecorder is used to indicate an expected call to the Method. ```go func (mr_2 *MockExampleMockRecorder) Method(_m, _mr, m, mr any) *gomock.Call ``` -------------------------------- ### VarargMethod Recorder for MockExample Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generated_identifier_conflict This method on MockExampleMockRecorder is used to indicate an expected call to the VarargMethod. ```go func (mr *MockExampleMockRecorder) VarargMethod(_s, _x, a, ret any, varargs ...any) *gomock.Call ``` -------------------------------- ### Define Post Struct Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/mock_name/post Defines the structure for a blog post, including its title, body, and author. ```go type Post struct { Title string Body string Author *user.User } ``` -------------------------------- ### NewMockWater Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generics/source Creates a new mock instance for the Water interface. ```APIDOC ## NewMockWater ### Description Creates a new mock instance for the `MockWater` type, which is a generic mock for a `Water` interface. ### Signature ```go func NewMockWater[R any, C generics.UnsignedInteger](ctrl *gomock.Controller) *MockWater[R, C] ``` ### Parameters * `ctrl` (*gomock.Controller) - The gomock controller to use for mocking. ``` -------------------------------- ### MockUrbanResidentWroomCall Methods Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/package_mode/mock Configures mock Wroom calls, offering Do, DoAndReturn, and Return functionalities. It wraps *gomock.Call and expects a function returning an error. ```go type MockUrbanResidentWroomCall struct { *gomock.Call } ``` ```go func (c *MockUrbanResidentWroomCall) Do(f func() error) *MockUrbanResidentWroomCall ``` ```go func (c *MockUrbanResidentWroomCall) DoAndReturn(f func() error) *MockUrbanResidentWroomCall ``` ```go func (c *MockUrbanResidentWroomCall) Return(arg0 error) *MockUrbanResidentWroomCall ``` -------------------------------- ### NewMockI Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/const_array_length Creates a new mock instance of the I interface. ```APIDOC ## NewMockI ### Description Creates a new mock instance. ### Signature ```go func NewMockI(ctrl *gomock.Controller) *MockI ``` ``` -------------------------------- ### DoAndReturn Method for MockQuxerConsumerConsumeCall Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/alias/mock Similar to Do, DoAndReturn allows specifying a function to execute, but it also handles returning values from that function. This is useful for more complex mock behavior. ```go func (c *MockQuxerConsumerConsumeCall) DoAndReturn(f func(alias.QuxerAlias) alias.QuxerAlias) *MockQuxerConsumerConsumeCall ``` -------------------------------- ### PostServiceMock EXPECT Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/mock_name/mocks Returns an object that allows the caller to specify expected method calls on the PostServiceMock. This is the entry point for setting up mock expectations. ```go func (m *PostServiceMock) EXPECT() *PostServiceMockMockRecorder ``` -------------------------------- ### Define Greeter Struct Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/custom_package_name/greeter Defines the Greeter struct, which includes dependencies for making input and a client. ```go type Greeter struct { InputMaker InputMaker Client *client.Client } ``` -------------------------------- ### Generated Mock for Interface Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/unexported_method Shows the structure of a generated mock for an interface. The mock includes fields for tracking expectations and methods for interacting with the mock recorder. ```go type MockExample struct { // contains filtered or unexported fields } ``` -------------------------------- ### Generate Mocks from Source Source: https://pkg.go.dev/go.uber.org/mock Use `mockgen` in source mode to generate mocks directly from a Go source file. The `-source` flag is required. ```bash mockgen -source=foo.go [other options] ``` -------------------------------- ### Define Client Interface Source: https://pkg.go.dev/go.uber.org/mock/bazel/tests/archive Defines the Client interface with a Connect method. This interface is used to establish connections. ```go type Client interface { Connect(string) int } ``` -------------------------------- ### Controller.WithContext Source: https://pkg.go.dev/go.uber.org/mock/gomock Creates a new Controller with an associated context. ```APIDOC ## func WithContext ```go func WithContext(ctx context.Context, t TestReporter) (*Controller, context.Context) ``` Creates a new Controller with an associated context. ``` -------------------------------- ### MockFooerAlias Foo Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/alias/mock Foo mocks the base method for MockFooerAlias. ```go func (m *MockFooerAlias) Foo() ``` -------------------------------- ### Greeter.Greet Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/custom_package_name/greeter The Greet method on the Greeter struct is used to generate a greeting string. It returns the greeting and an error if one occurs. ```APIDOC ## func (*Greeter) Greet ### Description Generates a greeting string. ### Signature ```go func (g *Greeter) Greet() (string, error) ``` ### Returns - `string`: The generated greeting. - `error`: An error if the greeting could not be generated. ``` -------------------------------- ### MockIntf Usage Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/internal_pkg/subdir/internal/pkg/reflect_output Provides details on creating and interacting with MockIntf, a mock implementation of the Intf interface. It includes functions for instantiation, expectation setting, and method mocking. ```APIDOC ## MockIntf ### Description MockIntf is a generated mock object for the Intf interface, used for testing purposes with the gomock library. ### Type Definition ```go type MockIntf struct { // contains filtered or unexported fields } ``` ### Functions #### NewMockIntf Creates a new mock instance of MockIntf. ```go func NewMockIntf(ctrl *gomock.Controller) *MockIntf ``` #### EXPECT Returns an object that allows the caller to indicate expected use of the mock. ```go func (m *MockIntf) EXPECT() *MockIntfMockRecorder ``` #### F Mocks the base method F of the Intf interface. ```go func (m *MockIntf) F() pkg.Arg ``` ## MockIntfMockRecorder ### Description MockIntfMockRecorder is the mock recorder for MockIntf, used to set up expectations on method calls. ### Type Definition ```go type MockIntfMockRecorder struct { // contains filtered or unexported fields } ``` ### Functions #### F Indicates an expected call to the F method on MockIntf. ```go func (mr *MockIntfMockRecorder) F() *gomock.Call ``` ``` -------------------------------- ### ChanType.String Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/model Returns the string representation of a ChanType. ```go func (ct *ChanType) String(pm map[string]string, pkgOverride string) string ``` -------------------------------- ### MockSolarSystem Water Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generics/source Mocks the base method 'Water' of the SolarSystem interface. This enables controlling the return value of Water during tests. ```go func (m *MockSolarSystem[T]) Water(arg0 T) []T ``` -------------------------------- ### Mock Method: Foo Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/const_array_length Mock implementation for the Foo method of the 'I' interface. It returns an array of size 2, referencing the constant C. ```go func (m *MockI) Foo() [2]int ``` -------------------------------- ### MockSolarSystemMockRecorder Methods Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generics%40v0.0.0-20251217210410-349aac660616/source Lists the methods available on the MockSolarSystemMockRecorder, used for setting expectations on the methods of a mocked SolarSystem. ```APIDOC ## MockSolarSystemMockRecorder ### Description Recorder for MockSolarSystem, used to set expectations on its methods. ``` -------------------------------- ### Define Client Struct Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/custom_package_name/client/v1 Defines the Client struct. This is a basic struct with no fields. ```go type Client struct{} ``` -------------------------------- ### MockInterfaceMockRecorder HelloWorld Method Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/build_flags/mock1 Indicates an expected call to the HelloWorld method on MockInterface. Used in conjunction with EXPECT(). ```go func (mr *MockInterfaceMockRecorder) HelloWorld() *gomock.Call ``` -------------------------------- ### MockMything.EXPECT Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/import_collision/p2/mocks Returns an object that allows the caller to indicate expected use of the MockMything interface. ```APIDOC ## func (*MockMything) EXPECT ### Description EXPECT returns an object that allows the caller to indicate expected use. ### Signature ```go func (m *MockMything) EXPECT() *MockMythingMockRecorder ``` ``` -------------------------------- ### Chaining Expected Call Order with Call.After Source: https://pkg.go.dev/go.uber.org/mock/gomock Demonstrates how to enforce a specific sequence of method calls on a mock object using the `After` method. This is useful when the order of operations is critical and needs to be verified during testing. ```go firstCall := mockObj.EXPECT().SomeMethod(1, "first") secondCall := mockObj.EXPECT().SomeMethod(2, "second").After(firstCall) mockObj.EXPECT().SomeMethod(3, "third").After(secondCall) ``` -------------------------------- ### Mocked VarargMethod Implementation Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/generated_identifier_conflict This is the implementation of the VarargMethod on the MockExample, part of the generated mock code. ```go func (m *MockExample) VarargMethod(_s, _x, a, ret int, varargs ...int) { } ``` -------------------------------- ### NewMockFooerAlias Constructor Source: https://pkg.go.dev/go.uber.org/mock/mockgen/internal/tests/alias/mock Creates a new mock instance for the FooerAlias interface. ```go func NewMockFooerAlias(ctrl *gomock.Controller) *MockFooerAlias ```