Full Code of golang/mock for AI

main 674a1c4a938e cached
135 files
312.4 KB
92.6k tokens
775 symbols
1 requests
Download .txt
Showing preview only (346K chars total). Download the full file or copy to clipboard to get everything.
Repository: golang/mock
Branch: main
Commit: 674a1c4a938e
Files: 135
Total size: 312.4 KB

Directory structure:
gitextract_uystbc9u/

├── .github/
│   ├── CODEOWNERS
│   ├── ISSUE_TEMPLATE/
│   │   ├── bug_report.md
│   │   ├── config.yml
│   │   └── feature_request.md
│   └── workflows/
│       └── test.yaml
├── .gitignore
├── .goreleaser.yml
├── AUTHORS
├── CONTRIBUTING.md
├── CONTRIBUTORS
├── LICENSE
├── README.md
├── ci/
│   ├── check_panic_handling.sh
│   └── test.sh
├── go.mod
├── go.sum
├── gomock/
│   ├── call.go
│   ├── call_test.go
│   ├── callset.go
│   ├── callset_test.go
│   ├── controller.go
│   ├── controller_test.go
│   ├── doc.go
│   ├── example_test.go
│   ├── internal/
│   │   └── mock_gomock/
│   │       └── mock_matcher.go
│   ├── matchers.go
│   ├── matchers_test.go
│   └── mock_test.go
├── mockgen/
│   ├── generic_go118.go
│   ├── generic_notgo118.go
│   ├── internal/
│   │   └── tests/
│   │       ├── aux_imports_embedded_interface/
│   │       │   ├── README.md
│   │       │   ├── bugreport.go
│   │       │   ├── bugreport_mock.go
│   │       │   ├── bugreport_test.go
│   │       │   └── faux/
│   │       │       └── faux.go
│   │       ├── const_array_length/
│   │       │   ├── input.go
│   │       │   └── mock.go
│   │       ├── copyright_file/
│   │       │   ├── input.go
│   │       │   ├── mock.go
│   │       │   └── mock_copyright_header
│   │       ├── custom_package_name/
│   │       │   ├── README.md
│   │       │   ├── client/
│   │       │   │   └── v1/
│   │       │   │       └── client.go
│   │       │   ├── greeter/
│   │       │   │   ├── greeter.go
│   │       │   │   ├── greeter_mock_test.go
│   │       │   │   └── greeter_test.go
│   │       │   └── validator/
│   │       │       └── validate.go
│   │       ├── dot_imports/
│   │       │   ├── input.go
│   │       │   └── mock.go
│   │       ├── empty_interface/
│   │       │   ├── input.go
│   │       │   └── mock.go
│   │       ├── extra_import/
│   │       │   ├── import.go
│   │       │   └── mock.go
│   │       ├── generated_identifier_conflict/
│   │       │   ├── README.md
│   │       │   ├── bugreport.go
│   │       │   ├── bugreport_mock.go
│   │       │   └── bugreport_test.go
│   │       ├── generics/
│   │       │   ├── external.go
│   │       │   ├── generics.go
│   │       │   ├── go.mod
│   │       │   ├── go.sum
│   │       │   ├── other/
│   │       │   │   └── other.go
│   │       │   └── source/
│   │       │       ├── mock_external_test.go
│   │       │       └── mock_generics_test.go
│   │       ├── import_embedded_interface/
│   │       │   ├── bugreport.go
│   │       │   ├── bugreport_mock.go
│   │       │   ├── bugreport_test.go
│   │       │   ├── ersatz/
│   │       │   │   └── ersatz.go
│   │       │   ├── faux/
│   │       │   │   ├── conflict.go
│   │       │   │   └── faux.go
│   │       │   ├── foo.go
│   │       │   ├── net.go
│   │       │   ├── net_mock.go
│   │       │   ├── net_test.go
│   │       │   └── other/
│   │       │       ├── ersatz/
│   │       │       │   └── ersatz.go
│   │       │       └── log/
│   │       │           └── log.go
│   │       ├── import_source/
│   │       │   ├── README.md
│   │       │   ├── definition/
│   │       │   │   ├── source.go
│   │       │   │   └── source_mock.go
│   │       │   └── source_mock.go
│   │       ├── internal_pkg/
│   │       │   ├── generate.go
│   │       │   └── subdir/
│   │       │       └── internal/
│   │       │           └── pkg/
│   │       │               ├── input.go
│   │       │               ├── reflect_output/
│   │       │               │   └── mock.go
│   │       │               └── source_output/
│   │       │                   └── mock.go
│   │       ├── missing_import/
│   │       │   ├── output/
│   │       │   │   └── source_mock.go
│   │       │   └── source/
│   │       │       └── source.go
│   │       ├── mock_in_test_package/
│   │       │   ├── README.md
│   │       │   ├── mock_test.go
│   │       │   └── user.go
│   │       ├── overlapping_methods/
│   │       │   ├── interfaces.go
│   │       │   ├── mock.go
│   │       │   ├── overlap.go
│   │       │   └── overlap_test.go
│   │       ├── panicing_test/
│   │       │   ├── mock_test.go
│   │       │   ├── panic.go
│   │       │   └── panic_test.go
│   │       ├── parenthesized_parameter_type/
│   │       │   ├── README.md
│   │       │   ├── input.go
│   │       │   └── mock.go
│   │       ├── performance/
│   │       │   └── big_interface/
│   │       │       └── big_interface.go
│   │       ├── self_package/
│   │       │   ├── mock.go
│   │       │   └── types.go
│   │       ├── test_package/
│   │       │   ├── foo.go
│   │       │   ├── mock_test.go
│   │       │   └── user_test.go
│   │       ├── unexported_method/
│   │       │   ├── README.md
│   │       │   ├── bugreport.go
│   │       │   ├── bugreport_mock.go
│   │       │   └── bugreport_test.go
│   │       ├── vendor_dep/
│   │       │   ├── README.md
│   │       │   ├── doc.go
│   │       │   ├── mock.go
│   │       │   ├── source_mock_package/
│   │       │   │   └── mock.go
│   │       │   └── vendor_dep.go
│   │       └── vendor_pkg/
│   │           ├── README.md
│   │           ├── doc.go
│   │           └── mock.go
│   ├── mockgen.go
│   ├── mockgen_test.go
│   ├── model/
│   │   ├── model.go
│   │   └── model_test.go
│   ├── parse.go
│   ├── parse_test.go
│   ├── reflect.go
│   └── version.go
└── sample/
    ├── README.md
    ├── concurrent/
    │   ├── concurrent.go
    │   ├── concurrent_test.go
    │   └── mock/
    │       └── concurrent_mock.go
    ├── imp1/
    │   └── imp1.go
    ├── imp2/
    │   └── imp2.go
    ├── imp3/
    │   └── imp3.go
    ├── imp4/
    │   └── imp4.go
    ├── mock_user_test.go
    ├── user.go
    └── user_test.go

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/CODEOWNERS
================================================
*                   @codyoss


================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Report a bug in gomock
title: ''
labels: ''
assignees: ''

---

**Actual behavior** A clear and concise description of what the bug is.

**Expected behavior** A clear and concise description of what you expected to
happen.

**To Reproduce** Steps to reproduce the behavior

1.  ...
2.  ...

**Additional Information**

-   gomock mode (reflect or source):
-   gomock version or git ref:
-   golang version:

**Triage Notes for the Maintainers**

<!-- 🎉🎉🎉 Thank you for an opening an issue !!! 🎉🎉🎉 We are doing our best to get to this. -->


================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
blank_issues_enabled: true
#contact_links:
#  - name: GitHub Community Forum
#    url: https://github.community/
#    about: Please ask and answer questions here.
#  - name: GitHub Security Bug Bounty
#    url: https://bounty.github.com/
#    about: Please report security vulnerabilities here.


================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Propose a new feature for gomock
title: ''
labels: 'type: feature request'
assignees: ''

---

*Requested feature* A clear description of the desired feature and an example of
how it would be used.

*Why the feature is needed* A clear description of how this feature is not
served by existing functionality in gomock.

*(Optional) Proposed solution* A clear description of a proposed method for
adding this feature to gomock.


================================================
FILE: .github/workflows/test.yaml
================================================
name: Run tests
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
env:
  GO111MODULE: on
jobs:
  test:
    strategy:
      matrix:
        go-version: [1.15.x, 1.18.x]
        os: [ubuntu-latest]
    runs-on: ${{ matrix.os }}
    steps:

    - name: Install Go
      uses: actions/setup-go@v2
      with:
        go-version: ${{ matrix.go-version }}

    - name: Checkout code
      uses: actions/checkout@v2

    - name: Vet and build
      run: |
        go vet ./...
        go build ./...

    - name: Install mockgen
      run: |
        go install github.com/golang/mock/mockgen

    - name: Run test script
      run: |
        ./ci/test.sh
        ./ci/check_panic_handling.sh

    - name: Run Go tests all
      if: ${{ startsWith(matrix.go-version, '1.18') }}
      run: |
        for i in $(find $PWD -name go.mod); do
          pushd $(dirname $i)
          go test ./...
          popd
        done 

    - name: Run Go tests some
      if: ${{ startsWith(matrix.go-version, '1.18') == false }}
      run: |
          go test ./...


================================================
FILE: .gitignore
================================================
# Object files and binaries from go.
*.[568]

# Library files.
*.a

# Any file prefixed by an underscore.
*/_*

# System
.*.swp
.DS_Store

# The mockgen binary.
mockgen/mockgen

# Editors
.vscode
.idea

# vendor directory used for IDEs
/vendor


================================================
FILE: .goreleaser.yml
================================================
# Release automation via GoReleaser (goreleaser.com)
# Requires a valid GITHUB_TOKEN envar prior to running `goreleaser`
# See https://goreleaser.com/environment/ for more info
---
release:
  github:
    owner: golang
    name: mock

builds:
  - binary: mockgen
    goos:
      - darwin
      - windows
      - linux
    goarch:
      - amd64
      - arm64
      - 386
    env:
      - CGO_ENABLED=0
      - GO111MODULE=on
      - GOPROXY=https://proxy.golang.org
      - GOSUMDB=sum.golang.org
    main: ./mockgen/

archives:
 - format: tar.gz
   wrap_in_directory: true
   files:
     - LICENSE
     - README.md
checksum:
snapshot:
  name_template: "snap-{{ .Commit }}"
changelog:
  sort: asc
  filters:
    exclude:
      - '^docs:'
      - '^test:'
      - 'README'


================================================
FILE: AUTHORS
================================================
# This is the official list of GoMock authors for copyright purposes.
# This file is distinct from the CONTRIBUTORS files.
# See the latter for an explanation.

# Names should be added to this file as
#	Name or Organization <email address>
# The email address is not required for organizations.

# Please keep the list sorted.

Alex Reece <awreece@gmail.com>
Google Inc.


================================================
FILE: CONTRIBUTING.md
================================================
# Contributing

First off, thank you for taking an interest to contribute to this project!

## Opening issues

When opening a [new issue](https://github.com/golang/mock/issues/new/choose)
please:

1. Make sure there are not other open/closed issues asking/reporting/requesting
   the same thing.
1. Choose one of our provided templates and fill out as much information as
   possible.

## Opening a Pull Requests

We gladly accept contributions from the community. Before opening a pull request
please make sure to create an issue for discussion first. This helps us decide
what action should be taken in regards to the issue.


================================================
FILE: CONTRIBUTORS
================================================
# This is the official list of people who can contribute (and typically
# have contributed) code to the gomock repository.
# The AUTHORS file lists the copyright holders; this file
# lists people.  For example, Google employees are listed here
# but not in AUTHORS, because Google holds the copyright.
#
# The submission process automatically checks to make sure
# that people submitting code are listed in this file (by email address).
#
# Names should be added to this file only after verifying that
# the individual or the individual's organization has agreed to
# the appropriate Contributor License Agreement, found here:
#
#     http://code.google.com/legal/individual-cla-v1.0.html
#     http://code.google.com/legal/corporate-cla-v1.0.html
#
# The agreement for individuals can be filled out on the web.
#
# When adding J Random Contributor's name to this file,
# either J's name or J's organization's name should be
# added to the AUTHORS file, depending on whether the
# individual or corporate CLA was used.

# Names should be added to this file like so:
#     Name <email address>
#
# An entry with two email addresses specifies that the
# first address should be used in the submit logs and
# that the second address should be recognized as the
# same person when interacting with Rietveld.

# Please keep the list sorted.

Aaron Jacobs <jacobsa@google.com> <aaronjjacobs@gmail.com>
Alex Reece <awreece@gmail.com>
David Symonds <dsymonds@golang.org>
Ryan Barrett <ryanb@google.com>


================================================
FILE: LICENSE
================================================

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: README.md
================================================
# gomock

**Update, June 2023**: _This repo and tool are no longer maintained.
Please see [go.uber.org/mock](https://github.com/uber/mock) for a maintained fork instead._

[![Build Status][ci-badge]][ci-runs] [![Go Reference][reference-badge]][reference]

gomock is a mocking framework for the [Go programming language][golang]. It
integrates well with Go's built-in `testing` package, but can be used in other
contexts too.

## Installation

Once you have [installed Go][golang-install], install the `mockgen` tool.

**Note**: If you have not done so already be sure to add `$GOPATH/bin` to your
`PATH`.

To get the latest released version use:

### Go version < 1.16

```bash
GO111MODULE=on go get github.com/golang/mock/mockgen@v1.6.0
```

### Go 1.16+

```bash
go install github.com/golang/mock/mockgen@v1.6.0
```

If you use `mockgen` in your CI pipeline, it may be more appropriate to fixate
on a specific mockgen version. You should try to keep the library in sync with
the version of mockgen used to generate your mocks.

## Running mockgen

`mockgen` has two modes of operation: source and reflect.

### Source mode

Source mode generates mock interfaces from a source file.
It is enabled by using the -source flag. Other flags that
may be useful in this mode are -imports and -aux_files.

Example:

```bash
mockgen -source=foo.go [other options]
```

### Reflect mode

Reflect mode generates mock interfaces by building a program
that uses reflection to understand interfaces. It is enabled
by passing two non-flag arguments: an import path, and a
comma-separated list of symbols.

You can use "." to refer to the current path's package.

Example:

```bash
mockgen database/sql/driver Conn,Driver

# Convenient for `go:generate`.
mockgen . Conn,Driver
```

### Flags

The `mockgen` command is used to generate source code for a mock
class given a Go source file containing interfaces to be mocked.
It supports the following flags:

- `-source`: A file containing interfaces to be mocked.

- `-destination`: A file to which to write the resulting source code. If you
  don't set this, the code is printed to standard output.

- `-package`: The package to use for the resulting mock class
  source code. If you don't set this, the package name is `mock_` concatenated
  with the package of the input file.

- `-imports`: A list of explicit imports that should be used in the resulting
  source code, specified as a comma-separated list of elements of the form
  `foo=bar/baz`, where `bar/baz` is the package being imported and `foo` is
  the identifier to use for the package in the generated source code.

- `-aux_files`: A list of additional files that should be consulted to
  resolve e.g. embedded interfaces defined in a different file. This is
  specified as a comma-separated list of elements of the form
  `foo=bar/baz.go`, where `bar/baz.go` is the source file and `foo` is the
  package name of that file used by the -source file.

- `-build_flags`: (reflect mode only) Flags passed verbatim to `go build`.

- `-mock_names`: A list of custom names for generated mocks. This is specified
  as a comma-separated list of elements of the form
  `Repository=MockSensorRepository,Endpoint=MockSensorEndpoint`, where
  `Repository` is the interface name and `MockSensorRepository` is the desired
  mock name (mock factory method and mock recorder will be named after the mock).
  If one of the interfaces has no custom name specified, then default naming
  convention will be used.

- `-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. This can happen if the mock's package is
  set to one of its inputs (usually the main one) and the output is stdio so
  mockgen cannot detect the final output package. Setting this flag will then
  tell mockgen which import to exclude.

- `-copyright_file`: Copyright file used to add copyright header to the resulting source code.

- `-debug_parser`: Print out parser results only.

- `-exec_only`: (reflect mode) If set, execute this reflection program.

- `-prog_only`: (reflect mode) Only generate the reflection program; write it to stdout and exit.

- `-write_package_comment`: Writes package documentation comment (godoc) if true. (default true)

For an example of the use of `mockgen`, see the `sample/` directory. In simple
cases, you will need only the `-source` flag.

## Building Mocks

```go
type Foo interface {
  Bar(x int) int
}

func SUT(f Foo) {
 // ...
}

```

```go
func TestFoo(t *testing.T) {
  ctrl := gomock.NewController(t)

  // Assert that Bar() is invoked.
  defer ctrl.Finish()

  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)
}
```

If you are using a Go version of 1.14+, a mockgen version of 1.5.0+, and are
passing a *testing.T into `gomock.NewController(t)` you no longer need to call
`ctrl.Finish()` explicitly. It will be called for you automatically from a self
registered [Cleanup](https://pkg.go.dev/testing?tab=doc#T.Cleanup) function.

## Building Stubs

```go
type Foo interface {
  Bar(x int) int
}

func SUT(f Foo) {
 // ...
}

```

```go
func TestFoo(t *testing.T) {
  ctrl := gomock.NewController(t)
  defer ctrl.Finish()

  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)
}
```

## Modifying Failure Messages

When a matcher reports a failure, it prints the received (`Got`) vs the
expected (`Want`) value.

```shell
Got: [3]
Want: is equal to 2
Expected call at user_test.go:33 doesn't match the argument at index 1.
Got: [0 1 1 2 3]
Want: is equal to 1
```

### Modifying `Want`

The `Want` value comes from the matcher's `String()` method. If the matcher's
default output doesn't meet your needs, then it can be modified as follows:

```go
gomock.WantFormatter(
  gomock.StringerFunc(func() string { return "is equal to fifteen" }),
  gomock.Eq(15),
)
```

This modifies the `gomock.Eq(15)` matcher's output for `Want:` from `is equal
to 15` to `is equal to fifteen`.

### Modifying `Got`

The `Got` value comes from the object's `String()` method if it is available.
In some cases the output of an object is difficult to read (e.g., `[]byte`) and
it would be helpful for the test to print it differently. The following
modifies how the `Got` value is formatted:

```go
gomock.GotFormatterAdapter(
  gomock.GotFormatterFunc(func(i interface{}) string {
    // Leading 0s
    return fmt.Sprintf("%02d", i)
  }),
  gomock.Eq(15),
)
```

If the received value is `3`, then it will be printed as `03`.

[golang]:              http://golang.org/
[golang-install]:      http://golang.org/doc/install.html#releases
[gomock-reference]:    https://pkg.go.dev/github.com/golang/mock/gomock
[ci-badge]:            https://github.com/golang/mock/actions/workflows/test.yaml/badge.svg
[ci-runs]:             https://github.com/golang/mock/actions
[reference-badge]:     https://pkg.go.dev/badge/github.com/golang/mock.svg
[reference]:           https://pkg.go.dev/github.com/golang/mock

## Debugging Errors

### reflect vendoring error

```text
cannot find package "."
... github.com/golang/mock/mockgen/model
```

If you come across this error while using reflect mode and vendoring
dependencies there are three workarounds you can choose from:

1. Use source mode.
2. Include an empty import `import _ "github.com/golang/mock/mockgen/model"`.
3. Add `--build_flags=--mod=mod` to your mockgen command.

This error is due to changes in default behavior of the `go` command in more
recent versions. More details can be found in
[#494](https://github.com/golang/mock/issues/494).


================================================
FILE: ci/check_panic_handling.sh
================================================
#!/bin/bash
# Copyright 2010 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script is used to ensure that panics are properly reported in tests.

set -eux

pushd mockgen/internal/tests/panicing_test
go test -v -tags=panictest -run TestDanger_Panics_Explicit | grep "Danger, Will Robinson!"
go test -v -tags=panictest -run TestDanger_Panics_Implicit | grep "Danger, Will Robinson!"
popd


================================================
FILE: ci/test.sh
================================================
#!/bin/bash
# This script is used to ensure that the go.mod file is up to date.

set -euo pipefail

if [[ $(go version) != *"go1.18"* ]]; then
  exit 0
fi

for i in $(find $PWD -name go.mod); do
  pushd $(dirname $i)
  go mod tidy
  popd
done

if [ ! -z "$(git status --porcelain)" ]; then
  git status
  git diff
  echo
  echo "The go.mod is not up to date."
  exit 1
fi

BASE_DIR="$PWD"
TEMP_DIR=$(mktemp -d)
function cleanup() {
  rm -rf "${TEMP_DIR}"
}
trap cleanup EXIT

cp -r . "${TEMP_DIR}/"
cd $TEMP_DIR

for i in $(find $PWD -name go.mod); do
  pushd $(dirname $i)
  go generate ./...
  popd
done

if ! diff -r . "${BASE_DIR}"; then
  echo
  echo "The generated files aren't up to date."
  echo "Update them with the 'go generate ./...' command."
  exit 1
fi


================================================
FILE: go.mod
================================================
module github.com/golang/mock

require (
	golang.org/x/mod v0.5.1
	golang.org/x/tools v0.1.8
)

go 1.15


================================================
FILE: go.sum
================================================
github.com/yuin/goldmark v1.4.1 h1:/vn0k+RBvwlxEmP5E7SZMqNxPhfMVFEJiykr15/0XKM=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.8 h1:P1HhGGuLW4aAclzjtmJdf0mJOjVUZUzOTqkAkWL+l6w=
golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=


================================================
FILE: gomock/call.go
================================================
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package gomock

import (
	"fmt"
	"reflect"
	"strconv"
	"strings"
)

// Call represents an expected call to a mock.
type Call struct {
	t TestHelper // for triggering test failures on invalid call setup

	receiver   interface{}  // the receiver of the method call
	method     string       // the name of the method
	methodType reflect.Type // the type of the method
	args       []Matcher    // the args
	origin     string       // file and line number of call setup

	preReqs []*Call // prerequisite calls

	// Expectations
	minCalls, maxCalls int

	numCalls int // actual number made

	// actions are called when this Call is called. Each action gets the args and
	// can set the return values by returning a non-nil slice. Actions run in the
	// order they are created.
	actions []func([]interface{}) []interface{}
}

// newCall creates a *Call. It requires the method type in order to support
// unexported methods.
func newCall(t TestHelper, receiver interface{}, method string, methodType reflect.Type, args ...interface{}) *Call {
	t.Helper()

	// TODO: check arity, types.
	mArgs := make([]Matcher, len(args))
	for i, arg := range args {
		if m, ok := arg.(Matcher); ok {
			mArgs[i] = m
		} else if arg == nil {
			// Handle nil specially so that passing a nil interface value
			// will match the typed nils of concrete args.
			mArgs[i] = Nil()
		} else {
			mArgs[i] = Eq(arg)
		}
	}

	// callerInfo's skip should be updated if the number of calls between the user's test
	// and this line changes, i.e. this code is wrapped in another anonymous function.
	// 0 is us, 1 is RecordCallWithMethodType(), 2 is the generated recorder, and 3 is the user's test.
	origin := callerInfo(3)
	actions := []func([]interface{}) []interface{}{func([]interface{}) []interface{} {
		// Synthesize the zero value for each of the return args' types.
		rets := make([]interface{}, methodType.NumOut())
		for i := 0; i < methodType.NumOut(); i++ {
			rets[i] = reflect.Zero(methodType.Out(i)).Interface()
		}
		return rets
	}}
	return &Call{t: t, receiver: receiver, method: method, methodType: methodType,
		args: mArgs, origin: origin, minCalls: 1, maxCalls: 1, actions: actions}
}

// AnyTimes allows the expectation to be called 0 or more times
func (c *Call) AnyTimes() *Call {
	c.minCalls, c.maxCalls = 0, 1e8 // close enough to infinity
	return c
}

// MinTimes requires the call to occur at least n times. If AnyTimes or MaxTimes have not been called or if MaxTimes
// was previously called with 1, MinTimes also sets the maximum number of calls to infinity.
func (c *Call) MinTimes(n int) *Call {
	c.minCalls = n
	if c.maxCalls == 1 {
		c.maxCalls = 1e8
	}
	return c
}

// MaxTimes limits the number of calls to n times. If AnyTimes or MinTimes have not been called or if MinTimes was
// previously called with 1, MaxTimes also sets the minimum number of calls to 0.
func (c *Call) MaxTimes(n int) *Call {
	c.maxCalls = n
	if c.minCalls == 1 {
		c.minCalls = 0
	}
	return c
}

// DoAndReturn declares the action to run when the call is matched.
// The return values from this function are returned by the mocked function.
// It takes an interface{} argument to support n-arity functions.
// The anonymous function must match the function signature mocked method.
func (c *Call) DoAndReturn(f interface{}) *Call {
	// TODO: Check arity and types here, rather than dying badly elsewhere.
	v := reflect.ValueOf(f)

	c.addAction(func(args []interface{}) []interface{} {
		c.t.Helper()
		ft := v.Type()
		if c.methodType.NumIn() != ft.NumIn() {
			if ft.IsVariadic() {
				c.t.Fatalf("wrong number of arguments in DoAndReturn func for %T.%v The function signature must match the mocked method, a variadic function cannot be used.",
					c.receiver, c.method)
			} else {
				c.t.Fatalf("wrong number of arguments in DoAndReturn func for %T.%v: got %d, want %d [%s]",
					c.receiver, c.method, ft.NumIn(), c.methodType.NumIn(), c.origin)
			}
			return nil
		}
		vArgs := make([]reflect.Value, len(args))
		for i := 0; i < len(args); i++ {
			if args[i] != nil {
				vArgs[i] = reflect.ValueOf(args[i])
			} else {
				// Use the zero value for the arg.
				vArgs[i] = reflect.Zero(ft.In(i))
			}
		}
		vRets := v.Call(vArgs)
		rets := make([]interface{}, len(vRets))
		for i, ret := range vRets {
			rets[i] = ret.Interface()
		}
		return rets
	})
	return c
}

// Do declares the action to run when the call is matched. The function's
// return values are ignored to retain backward compatibility. To use the
// return values call DoAndReturn.
// It takes an interface{} argument to support n-arity functions.
// The anonymous function must match the function signature mocked method.
func (c *Call) Do(f interface{}) *Call {
	// TODO: Check arity and types here, rather than dying badly elsewhere.
	v := reflect.ValueOf(f)

	c.addAction(func(args []interface{}) []interface{} {
		c.t.Helper()
		ft := v.Type()
		if c.methodType.NumIn() != ft.NumIn() {
			if ft.IsVariadic() {
				c.t.Fatalf("wrong number of arguments in Do func for %T.%v The function signature must match the mocked method, a variadic function cannot be used.",
					c.receiver, c.method)
			} else {
				c.t.Fatalf("wrong number of arguments in Do func for %T.%v: got %d, want %d [%s]",
					c.receiver, c.method, ft.NumIn(), c.methodType.NumIn(), c.origin)
			}
			return nil
		}
		vArgs := make([]reflect.Value, len(args))
		for i := 0; i < len(args); i++ {
			if args[i] != nil {
				vArgs[i] = reflect.ValueOf(args[i])
			} else {
				// Use the zero value for the arg.
				vArgs[i] = reflect.Zero(ft.In(i))
			}
		}
		v.Call(vArgs)
		return nil
	})
	return c
}

// Return declares the values to be returned by the mocked function call.
func (c *Call) Return(rets ...interface{}) *Call {
	c.t.Helper()

	mt := c.methodType
	if len(rets) != mt.NumOut() {
		c.t.Fatalf("wrong number of arguments to Return for %T.%v: got %d, want %d [%s]",
			c.receiver, c.method, len(rets), mt.NumOut(), c.origin)
	}
	for i, ret := range rets {
		if got, want := reflect.TypeOf(ret), mt.Out(i); got == want {
			// Identical types; nothing to do.
		} else if got == nil {
			// Nil needs special handling.
			switch want.Kind() {
			case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
				// ok
			default:
				c.t.Fatalf("argument %d to Return for %T.%v is nil, but %v is not nillable [%s]",
					i, c.receiver, c.method, want, c.origin)
			}
		} else if got.AssignableTo(want) {
			// Assignable type relation. Make the assignment now so that the generated code
			// can return the values with a type assertion.
			v := reflect.New(want).Elem()
			v.Set(reflect.ValueOf(ret))
			rets[i] = v.Interface()
		} else {
			c.t.Fatalf("wrong type of argument %d to Return for %T.%v: %v is not assignable to %v [%s]",
				i, c.receiver, c.method, got, want, c.origin)
		}
	}

	c.addAction(func([]interface{}) []interface{} {
		return rets
	})

	return c
}

// Times declares the exact number of times a function call is expected to be executed.
func (c *Call) Times(n int) *Call {
	c.minCalls, c.maxCalls = n, n
	return c
}

// SetArg declares an action that will set the nth argument's value,
// indirected through a pointer. Or, in the case of a slice and map, SetArg
// will copy value's elements/key-value pairs into the nth argument.
func (c *Call) SetArg(n int, value interface{}) *Call {
	c.t.Helper()

	mt := c.methodType
	// TODO: This will break on variadic methods.
	// We will need to check those at invocation time.
	if n < 0 || n >= mt.NumIn() {
		c.t.Fatalf("SetArg(%d, ...) called for a method with %d args [%s]",
			n, mt.NumIn(), c.origin)
	}
	// Permit setting argument through an interface.
	// In the interface case, we don't (nay, can't) check the type here.
	at := mt.In(n)
	switch at.Kind() {
	case reflect.Ptr:
		dt := at.Elem()
		if vt := reflect.TypeOf(value); !vt.AssignableTo(dt) {
			c.t.Fatalf("SetArg(%d, ...) argument is a %v, not assignable to %v [%s]",
				n, vt, dt, c.origin)
		}
	case reflect.Interface:
		// nothing to do
	case reflect.Slice:
		// nothing to do
	case reflect.Map:
		// nothing to do
	default:
		c.t.Fatalf("SetArg(%d, ...) referring to argument of non-pointer non-interface non-slice non-map type %v [%s]",
			n, at, c.origin)
	}

	c.addAction(func(args []interface{}) []interface{} {
		v := reflect.ValueOf(value)
		switch reflect.TypeOf(args[n]).Kind() {
		case reflect.Slice:
			setSlice(args[n], v)
		case reflect.Map:
			setMap(args[n], v)
		default:
			reflect.ValueOf(args[n]).Elem().Set(v)
		}
		return nil
	})
	return c
}

// isPreReq returns true if other is a direct or indirect prerequisite to c.
func (c *Call) isPreReq(other *Call) bool {
	for _, preReq := range c.preReqs {
		if other == preReq || preReq.isPreReq(other) {
			return true
		}
	}
	return false
}

// After declares that the call may only match after preReq has been exhausted.
func (c *Call) After(preReq *Call) *Call {
	c.t.Helper()

	if c == preReq {
		c.t.Fatalf("A call isn't allowed to be its own prerequisite")
	}
	if preReq.isPreReq(c) {
		c.t.Fatalf("Loop in call order: %v is a prerequisite to %v (possibly indirectly).", c, preReq)
	}

	c.preReqs = append(c.preReqs, preReq)
	return c
}

// Returns true if the minimum number of calls have been made.
func (c *Call) satisfied() bool {
	return c.numCalls >= c.minCalls
}

// Returns true if the maximum number of calls have been made.
func (c *Call) exhausted() bool {
	return c.numCalls >= c.maxCalls
}

func (c *Call) String() string {
	args := make([]string, len(c.args))
	for i, arg := range c.args {
		args[i] = arg.String()
	}
	arguments := strings.Join(args, ", ")
	return fmt.Sprintf("%T.%v(%s) %s", c.receiver, c.method, arguments, c.origin)
}

// Tests if the given call matches the expected call.
// If yes, returns nil. If no, returns error with message explaining why it does not match.
func (c *Call) matches(args []interface{}) error {
	if !c.methodType.IsVariadic() {
		if len(args) != len(c.args) {
			return fmt.Errorf("expected call at %s has the wrong number of arguments. Got: %d, want: %d",
				c.origin, len(args), len(c.args))
		}

		for i, m := range c.args {
			if !m.Matches(args[i]) {
				return fmt.Errorf(
					"expected call at %s doesn't match the argument at index %d.\nGot: %v\nWant: %v",
					c.origin, i, formatGottenArg(m, args[i]), m,
				)
			}
		}
	} else {
		if len(c.args) < c.methodType.NumIn()-1 {
			return fmt.Errorf("expected call at %s has the wrong number of matchers. Got: %d, want: %d",
				c.origin, len(c.args), c.methodType.NumIn()-1)
		}
		if len(c.args) != c.methodType.NumIn() && len(args) != len(c.args) {
			return fmt.Errorf("expected call at %s has the wrong number of arguments. Got: %d, want: %d",
				c.origin, len(args), len(c.args))
		}
		if len(args) < len(c.args)-1 {
			return fmt.Errorf("expected call at %s has the wrong number of arguments. Got: %d, want: greater than or equal to %d",
				c.origin, len(args), len(c.args)-1)
		}

		for i, m := range c.args {
			if i < c.methodType.NumIn()-1 {
				// Non-variadic args
				if !m.Matches(args[i]) {
					return fmt.Errorf("expected call at %s doesn't match the argument at index %s.\nGot: %v\nWant: %v",
						c.origin, strconv.Itoa(i), formatGottenArg(m, args[i]), m)
				}
				continue
			}
			// The last arg has a possibility of a variadic argument, so let it branch

			// sample: Foo(a int, b int, c ...int)
			if i < len(c.args) && i < len(args) {
				if m.Matches(args[i]) {
					// Got Foo(a, b, c) want Foo(matcherA, matcherB, gomock.Any())
					// Got Foo(a, b, c) want Foo(matcherA, matcherB, someSliceMatcher)
					// Got Foo(a, b, c) want Foo(matcherA, matcherB, matcherC)
					// Got Foo(a, b) want Foo(matcherA, matcherB)
					// Got Foo(a, b, c, d) want Foo(matcherA, matcherB, matcherC, matcherD)
					continue
				}
			}

			// The number of actual args don't match the number of matchers,
			// or the last matcher is a slice and the last arg is not.
			// If this function still matches it is because the last matcher
			// matches all the remaining arguments or the lack of any.
			// Convert the remaining arguments, if any, into a slice of the
			// expected type.
			vArgsType := c.methodType.In(c.methodType.NumIn() - 1)
			vArgs := reflect.MakeSlice(vArgsType, 0, len(args)-i)
			for _, arg := range args[i:] {
				vArgs = reflect.Append(vArgs, reflect.ValueOf(arg))
			}
			if m.Matches(vArgs.Interface()) {
				// Got Foo(a, b, c, d, e) want Foo(matcherA, matcherB, gomock.Any())
				// Got Foo(a, b, c, d, e) want Foo(matcherA, matcherB, someSliceMatcher)
				// Got Foo(a, b) want Foo(matcherA, matcherB, gomock.Any())
				// Got Foo(a, b) want Foo(matcherA, matcherB, someEmptySliceMatcher)
				break
			}
			// Wrong number of matchers or not match. Fail.
			// Got Foo(a, b) want Foo(matcherA, matcherB, matcherC, matcherD)
			// Got Foo(a, b, c) want Foo(matcherA, matcherB, matcherC, matcherD)
			// Got Foo(a, b, c, d) want Foo(matcherA, matcherB, matcherC, matcherD, matcherE)
			// Got Foo(a, b, c, d, e) want Foo(matcherA, matcherB, matcherC, matcherD)
			// Got Foo(a, b, c) want Foo(matcherA, matcherB)

			return fmt.Errorf("expected call at %s doesn't match the argument at index %s.\nGot: %v\nWant: %v",
				c.origin, strconv.Itoa(i), formatGottenArg(m, args[i:]), c.args[i])
		}
	}

	// Check that all prerequisite calls have been satisfied.
	for _, preReqCall := range c.preReqs {
		if !preReqCall.satisfied() {
			return fmt.Errorf("expected call at %s doesn't have a prerequisite call satisfied:\n%v\nshould be called before:\n%v",
				c.origin, preReqCall, c)
		}
	}

	// Check that the call is not exhausted.
	if c.exhausted() {
		return fmt.Errorf("expected call at %s has already been called the max number of times", c.origin)
	}

	return nil
}

// dropPrereqs tells the expected Call to not re-check prerequisite calls any
// longer, and to return its current set.
func (c *Call) dropPrereqs() (preReqs []*Call) {
	preReqs = c.preReqs
	c.preReqs = nil
	return
}

func (c *Call) call() []func([]interface{}) []interface{} {
	c.numCalls++
	return c.actions
}

// InOrder declares that the given calls should occur in order.
func InOrder(calls ...*Call) {
	for i := 1; i < len(calls); i++ {
		calls[i].After(calls[i-1])
	}
}

func setSlice(arg interface{}, v reflect.Value) {
	va := reflect.ValueOf(arg)
	for i := 0; i < v.Len(); i++ {
		va.Index(i).Set(v.Index(i))
	}
}

func setMap(arg interface{}, v reflect.Value) {
	va := reflect.ValueOf(arg)
	for _, e := range va.MapKeys() {
		va.SetMapIndex(e, reflect.Value{})
	}
	for _, e := range v.MapKeys() {
		va.SetMapIndex(e, v.MapIndex(e))
	}
}

func (c *Call) addAction(action func([]interface{}) []interface{}) {
	c.actions = append(c.actions, action)
}

func formatGottenArg(m Matcher, arg interface{}) string {
	got := fmt.Sprintf("%v (%T)", arg, arg)
	if gs, ok := m.(GotFormatter); ok {
		got = gs.Got(arg)
	}
	return got
}


================================================
FILE: gomock/call_test.go
================================================
// Copyright 2020 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package gomock

import (
	"fmt"
	"reflect"
	"testing"
)

type foo struct{}

func (f foo) String() string {
	return "meow"
}

type a struct {
	name string
}

func (testObj a) Name() string {
	return testObj.name
}

type b struct {
	foo string
}

func (testObj b) Foo() string {
	return testObj.foo
}

type mockTestReporter struct {
	errorCalls int
	fatalCalls int
}

func (o *mockTestReporter) Errorf(format string, args ...interface{}) {
	o.errorCalls++
}

func (o *mockTestReporter) Fatalf(format string, args ...interface{}) {
	o.fatalCalls++
}

func (o *mockTestReporter) Helper() {}

func TestCall_After(t *testing.T) {
	t.Run("SelfPrereqCallsFatalf", func(t *testing.T) {
		tr1 := &mockTestReporter{}

		c := &Call{t: tr1}
		c.After(c)

		if tr1.fatalCalls != 1 {
			t.Errorf("number of fatal calls == %v, want 1", tr1.fatalCalls)
		}
	})

	t.Run("LoopInCallOrderCallsFatalf", func(t *testing.T) {
		tr1 := &mockTestReporter{}
		tr2 := &mockTestReporter{}

		c1 := &Call{t: tr1}
		c2 := &Call{t: tr2}
		c1.After(c2)
		c2.After(c1)

		if tr1.errorCalls != 0 || tr1.fatalCalls != 0 {
			t.Error("unexpected errors")
		}

		if tr2.fatalCalls != 1 {
			t.Errorf("number of fatal calls == %v, want 1", tr2.fatalCalls)
		}
	})
}

func prepareDoCall(doFunc, callFunc interface{}) *Call {
	tr := &mockTestReporter{}

	c := &Call{
		t:          tr,
		methodType: reflect.TypeOf(callFunc),
	}

	c.Do(doFunc)

	return c
}

func prepareDoAndReturnCall(doFunc, callFunc interface{}) *Call {
	tr := &mockTestReporter{}

	c := &Call{
		t:          tr,
		methodType: reflect.TypeOf(callFunc),
	}

	c.DoAndReturn(doFunc)

	return c
}

type testCase struct {
	description string
	doFunc      interface{}
	callFunc    interface{}
	args        []interface{}
	expectPanic bool
}

var testCases []testCase = []testCase{
	{
		description: "argument to Do is not a function",
		doFunc:      "meow",
		callFunc:    func(x int, y int) {},
		args:        []interface{}{0, 1},
		expectPanic: true,
	}, {
		description: "argument to Do is not a function",
		doFunc:      "meow",
		callFunc: func(x int, y int) bool {
			return true
		},
		args:        []interface{}{0, 1},
		expectPanic: true,
	}, {
		description: "number of args for Do func don't match Call func",
		doFunc:      func(x int) {},
		callFunc:    func(x int, y int) {},
		args:        []interface{}{0, 1},
		expectPanic: false,
	}, {
		description: "number of args for Do func don't match Call func",
		doFunc: func(x int) bool {
			return true
		},
		callFunc: func(x int, y int) bool {
			return true
		},
		args:        []interface{}{0, 1},
		expectPanic: false,
	}, {
		description: "arg type for Do func incompatible with Call func",
		doFunc:      func(x int) {},
		callFunc:    func(x string) {},
		args:        []interface{}{"meow"},
		expectPanic: true,
	}, {
		description: "arg type for Do func incompatible with Call func",
		doFunc: func(x int) bool {
			return true
		},
		callFunc: func(x string) bool {
			return true
		},
		args:        []interface{}{"meow"},
		expectPanic: true,
	}, {
		description: "Do func(int) Call func(int)",
		doFunc:      func(x int) {},
		callFunc:    func(x int) {},
		args:        []interface{}{0},
	}, {
		description: "Do func(int) Call func(interface{})",
		doFunc:      func(x int) {},
		callFunc:    func(x interface{}) {},
		args:        []interface{}{0},
	}, {
		description: "Do func(int) bool Call func(int) bool",
		doFunc: func(x int) bool {
			return true
		},
		callFunc: func(x int) bool {
			return true
		},
		args: []interface{}{0},
	}, {
		description: "Do func(int) bool Call func(interface{}) bool",
		doFunc: func(x int) bool {
			return true
		},
		callFunc: func(x interface{}) bool {
			return true
		},
		args: []interface{}{0},
	}, {
		description: "Do func(string) Call func([]byte)",
		doFunc:      func(x string) {},
		callFunc:    func(x []byte) {},
		args:        []interface{}{[]byte("meow")},
		expectPanic: true,
	}, {
		description: "Do func(string) bool Call func([]byte) bool",
		doFunc: func(x string) bool {
			return true
		},
		callFunc: func(x []byte) bool {
			return true
		},
		args:        []interface{}{[]byte("meow")},
		expectPanic: true,
	}, {
		description: "Do func(map[int]string) Call func(map[interface{}]int)",
		doFunc:      func(x map[int]string) {},
		callFunc:    func(x map[interface{}]int) {},
		args:        []interface{}{map[interface{}]int{"meow": 0}},
		expectPanic: true,
	}, {
		description: "Do func(map[int]string) Call func(map[interface{}]interface{})",
		doFunc:      func(x map[int]string) {},
		callFunc:    func(x map[interface{}]interface{}) {},
		args:        []interface{}{map[interface{}]interface{}{"meow": "meow"}},
		expectPanic: true,
	}, {
		description: "Do func(map[int]string) bool Call func(map[interface{}]int) bool",
		doFunc: func(x map[int]string) bool {
			return true
		},
		callFunc: func(x map[interface{}]int) bool {
			return true
		},
		args:        []interface{}{map[interface{}]int{"meow": 0}},
		expectPanic: true,
	}, {
		description: "Do func(map[int]string) bool Call func(map[interface{}]interface{}) bool",
		doFunc: func(x map[int]string) bool {
			return true
		},
		callFunc: func(x map[interface{}]interface{}) bool {
			return true
		},
		args:        []interface{}{map[interface{}]interface{}{"meow": "meow"}},
		expectPanic: true,
	}, {
		description: "Do func([]string) Call func([]interface{})",
		doFunc:      func(x []string) {},
		callFunc:    func(x []interface{}) {},
		args:        []interface{}{[]interface{}{0}},
		expectPanic: true,
	}, {
		description: "Do func([]string) Call func([]int)",
		doFunc:      func(x []string) {},
		callFunc:    func(x []int) {},
		args:        []interface{}{[]int{0, 1}},
		expectPanic: true,
	}, {
		description: "Do func([]int) Call func([]int)",
		doFunc:      func(x []int) {},
		callFunc:    func(x []int) {},
		args:        []interface{}{[]int{0, 1}},
	}, {
		description: "Do func([]int) Call func([]interface{})",
		doFunc:      func(x []int) {},
		callFunc:    func(x []interface{}) {},
		args:        []interface{}{[]interface{}{0}},
		expectPanic: true,
	}, {
		description: "Do func([]int) Call func(...interface{})",
		doFunc:      func(x []int) {},
		callFunc:    func(x ...interface{}) {},
		args:        []interface{}{0, 1},
		expectPanic: true,
	}, {
		description: "Do func([]int) Call func(...int)",
		doFunc:      func(x []int) {},
		callFunc:    func(x ...int) {},
		args:        []interface{}{0, 1},
		expectPanic: true,
	}, {
		description: "Do func([]string) bool Call func([]interface{}) bool",
		doFunc: func(x []string) bool {
			return true
		},
		callFunc: func(x []interface{}) bool {
			return true
		},
		args:        []interface{}{[]interface{}{0}},
		expectPanic: true,
	}, {
		description: "Do func([]string) bool Call func([]int) bool",
		doFunc: func(x []string) bool {
			return true
		},
		callFunc: func(x []int) bool {
			return true
		},
		args:        []interface{}{[]int{0, 1}},
		expectPanic: true,
	}, {
		description: "Do func([]int) bool Call func([]int) bool",
		doFunc: func(x []int) bool {
			return true
		},
		callFunc: func(x []int) bool {
			return true
		},
		args: []interface{}{[]int{0, 1}},
	}, {
		description: "Do func([]int) bool Call func([]interface{}) bool",
		doFunc: func(x []int) bool {
			return true
		},
		callFunc: func(x []interface{}) bool {
			return true
		},
		args:        []interface{}{[]interface{}{0}},
		expectPanic: true,
	}, {
		description: "Do func([]int) bool Call func(...interface{}) bool",
		doFunc: func(x []int) bool {
			return true
		},
		callFunc: func(x ...interface{}) bool {
			return true
		},
		args:        []interface{}{0, 1},
		expectPanic: true,
	}, {
		description: "Do func([]int) bool Call func(...int) bool",
		doFunc: func(x []int) bool {
			return true
		},
		callFunc: func(x ...int) bool {
			return true
		},
		args:        []interface{}{0, 1},
		expectPanic: true,
	}, {
		description: "Do func(...int) Call func([]int)",
		doFunc:      func(x ...int) {},
		callFunc:    func(x []int) {},
		args:        []interface{}{[]int{0, 1}},
		expectPanic: true,
	}, {
		description: "Do func(...int) Call func([]interface{})",
		doFunc:      func(x ...int) {},
		callFunc:    func(x []interface{}) {},
		args:        []interface{}{[]interface{}{0, 1}},
		expectPanic: true,
	}, {
		description: "Do func(...int) Call func(...interface{})",
		doFunc:      func(x ...int) {},
		callFunc:    func(x ...interface{}) {},
		args:        []interface{}{0, 1},
	}, {
		description: "Do func(...int) bool Call func(...int) bool",
		doFunc: func(x ...int) bool {
			return true
		},
		callFunc: func(x ...int) bool {
			return true
		},
		args: []interface{}{0, 1},
	}, {
		description: "Do func(...int) bool Call func([]int) bool",
		doFunc: func(x ...int) bool {
			return true
		},
		callFunc: func(x []int) bool {
			return true
		},
		args:        []interface{}{[]int{0, 1}},
		expectPanic: true,
	}, {
		description: "Do func(...int) bool Call func([]interface{}) bool",
		doFunc: func(x ...int) bool {
			return true
		},
		callFunc: func(x []interface{}) bool {
			return true
		},
		args:        []interface{}{[]interface{}{0, 1}},
		expectPanic: true,
	}, {
		description: "Do func(...int) bool Call func(...interface{}) bool",
		doFunc: func(x ...int) bool {
			return true
		},
		callFunc: func(x ...interface{}) bool {
			return true
		},
		args: []interface{}{0, 1},
	}, {
		description: "Do func(...int) Call func(...int)",
		doFunc:      func(x ...int) {},
		callFunc:    func(x ...int) {},
		args:        []interface{}{0, 1},
	}, {
		description: "Do func(foo); foo implements interface X Call func(interface X)",
		doFunc:      func(x foo) {},
		callFunc:    func(x fmt.Stringer) {},
		args:        []interface{}{foo{}},
	}, {
		description: "Do func(b); b does not implement interface X Call func(interface X)",
		doFunc:      func(x b) {},
		callFunc:    func(x fmt.Stringer) {},
		args:        []interface{}{foo{}},
		expectPanic: true,
	}, {
		description: "Do func(b) Call func(a); a and b are not aliases",
		doFunc:      func(x b) {},
		callFunc:    func(x a) {},
		args:        []interface{}{a{}},
		expectPanic: true,
	}, {
		description: "Do func(foo) bool; foo implements interface X Call func(interface X) bool",
		doFunc: func(x foo) bool {
			return true
		},
		callFunc: func(x fmt.Stringer) bool {
			return true
		},
		args: []interface{}{foo{}},
	}, {
		description: "Do func(b) bool; b does not implement interface X Call func(interface X) bool",
		doFunc: func(x b) bool {
			return true
		},
		callFunc: func(x fmt.Stringer) bool {
			return true
		},
		args:        []interface{}{foo{}},
		expectPanic: true,
	}, {
		description: "Do func(b) bool Call func(a) bool; a and b are not aliases",
		doFunc: func(x b) bool {
			return true
		},
		callFunc: func(x a) bool {
			return true
		},
		args:        []interface{}{a{}},
		expectPanic: true,
	}, {
		description: "Do func(bool) b Call func(bool) a; a and b are not aliases",
		doFunc: func(x bool) b {
			return b{}
		},
		callFunc: func(x bool) a {
			return a{}
		},
		args: []interface{}{true},
	},
}

func TestCall_Do(t *testing.T) {
	for _, tc := range testCases {
		t.Run(tc.description, func(t *testing.T) {
			c := prepareDoCall(tc.doFunc, tc.callFunc)

			if len(c.actions) != 1 {
				t.Errorf("expected %d actions but got %d", 1, len(c.actions))
			}

			action := c.actions[0]

			if tc.expectPanic {
				defer func() {
					if r := recover(); r == nil {
						t.Error("expected Do to panic")
					}
				}()
			}

			action(tc.args)
		})
	}
}

func TestCall_Do_NumArgValidation(t *testing.T) {
	tests := []struct {
		name       string
		methodType reflect.Type
		doFn       interface{}
		args       []interface{}
		wantErr    bool
	}{
		{
			name:       "too few",
			methodType: reflect.TypeOf(func(one, two string) {}),
			doFn:       func(one string) {},
			args:       []interface{}{"too", "few"},
			wantErr:    true,
		},
		{
			name:       "too many",
			methodType: reflect.TypeOf(func(one, two string) {}),
			doFn:       func(one, two, three string) {},
			args:       []interface{}{"too", "few"},
			wantErr:    true,
		},
		{
			name:       "just right",
			methodType: reflect.TypeOf(func(one, two string) {}),
			doFn:       func(one string, two string) {},
			args:       []interface{}{"just", "right"},
			wantErr:    false,
		},
		{
			name:       "variadic",
			methodType: reflect.TypeOf(func(one, two string) {}),
			doFn:       func(args ...interface{}) {},
			args:       []interface{}{"just", "right"},
			wantErr:    true,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			tr := &mockTestReporter{}
			call := &Call{
				t:          tr,
				methodType: tt.methodType,
			}
			call.Do(tt.doFn)
			call.actions[0](tt.args)
			if tt.wantErr && tr.fatalCalls != 1 {
				t.Fatalf("expected call to fail")
			}
			if !tt.wantErr && tr.fatalCalls != 0 {
				t.Fatalf("expected call to pass")
			}
		})
	}
}

func TestCall_DoAndReturn_NumArgValidation(t *testing.T) {
	tests := []struct {
		name       string
		methodType reflect.Type
		doFn       interface{}
		args       []interface{}
		wantErr    bool
	}{
		{
			name:       "too few",
			methodType: reflect.TypeOf(func(one, two string) string { return "" }),
			doFn:       func(one string) {},
			args:       []interface{}{"too", "few"},
			wantErr:    true,
		},
		{
			name:       "too many",
			methodType: reflect.TypeOf(func(one, two string) string { return "" }),
			doFn:       func(one, two, three string) string { return "" },
			args:       []interface{}{"too", "few"},
			wantErr:    true,
		},
		{
			name:       "just right",
			methodType: reflect.TypeOf(func(one, two string) string { return "" }),
			doFn:       func(one string, two string) string { return "" },
			args:       []interface{}{"just", "right"},
			wantErr:    false,
		},
		{
			name:       "variadic",
			methodType: reflect.TypeOf(func(one, two string) {}),
			doFn:       func(args ...interface{}) string { return "" },
			args:       []interface{}{"just", "right"},
			wantErr:    true,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			tr := &mockTestReporter{}
			call := &Call{
				t:          tr,
				methodType: tt.methodType,
			}
			call.DoAndReturn(tt.doFn)
			call.actions[0](tt.args)
			if tt.wantErr && tr.fatalCalls != 1 {
				t.Fatalf("expected call to fail")
			}
			if !tt.wantErr && tr.fatalCalls != 0 {
				t.Fatalf("expected call to pass")
			}
		})
	}
}

func TestCall_DoAndReturn(t *testing.T) {
	for _, tc := range testCases {
		t.Run(tc.description, func(t *testing.T) {
			c := prepareDoAndReturnCall(tc.doFunc, tc.callFunc)

			if len(c.actions) != 1 {
				t.Errorf("expected %d actions but got %d", 1, len(c.actions))
			}

			action := c.actions[0]

			if tc.expectPanic {
				defer func() {
					if r := recover(); r == nil {
						t.Error("expected DoAndReturn to panic")
					}
				}()
			}

			action(tc.args)
		})
	}
}


================================================
FILE: gomock/callset.go
================================================
// Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package gomock

import (
	"bytes"
	"errors"
	"fmt"
)

// callSet represents a set of expected calls, indexed by receiver and method
// name.
type callSet struct {
	// Calls that are still expected.
	expected map[callSetKey][]*Call
	// Calls that have been exhausted.
	exhausted map[callSetKey][]*Call
}

// callSetKey is the key in the maps in callSet
type callSetKey struct {
	receiver interface{}
	fname    string
}

func newCallSet() *callSet {
	return &callSet{make(map[callSetKey][]*Call), make(map[callSetKey][]*Call)}
}

// Add adds a new expected call.
func (cs callSet) Add(call *Call) {
	key := callSetKey{call.receiver, call.method}
	m := cs.expected
	if call.exhausted() {
		m = cs.exhausted
	}
	m[key] = append(m[key], call)
}

// Remove removes an expected call.
func (cs callSet) Remove(call *Call) {
	key := callSetKey{call.receiver, call.method}
	calls := cs.expected[key]
	for i, c := range calls {
		if c == call {
			// maintain order for remaining calls
			cs.expected[key] = append(calls[:i], calls[i+1:]...)
			cs.exhausted[key] = append(cs.exhausted[key], call)
			break
		}
	}
}

// FindMatch searches for a matching call. Returns error with explanation message if no call matched.
func (cs callSet) FindMatch(receiver interface{}, method string, args []interface{}) (*Call, error) {
	key := callSetKey{receiver, method}

	// Search through the expected calls.
	expected := cs.expected[key]
	var callsErrors bytes.Buffer
	for _, call := range expected {
		err := call.matches(args)
		if err != nil {
			_, _ = fmt.Fprintf(&callsErrors, "\n%v", err)
		} else {
			return call, nil
		}
	}

	// If we haven't found a match then search through the exhausted calls so we
	// get useful error messages.
	exhausted := cs.exhausted[key]
	for _, call := range exhausted {
		if err := call.matches(args); err != nil {
			_, _ = fmt.Fprintf(&callsErrors, "\n%v", err)
			continue
		}
		_, _ = fmt.Fprintf(
			&callsErrors, "all expected calls for method %q have been exhausted", method,
		)
	}

	if len(expected)+len(exhausted) == 0 {
		_, _ = fmt.Fprintf(&callsErrors, "there are no expected calls of the method %q for that receiver", method)
	}

	return nil, errors.New(callsErrors.String())
}

// Failures returns the calls that are not satisfied.
func (cs callSet) Failures() []*Call {
	failures := make([]*Call, 0, len(cs.expected))
	for _, calls := range cs.expected {
		for _, call := range calls {
			if !call.satisfied() {
				failures = append(failures, call)
			}
		}
	}
	return failures
}


================================================
FILE: gomock/callset_test.go
================================================
// Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package gomock

import (
	"reflect"
	"testing"
)

type receiverType struct{}

func (receiverType) Func() {}

func TestCallSetAdd(t *testing.T) {
	method := "TestMethod"
	var receiver interface{} = "TestReceiver"
	cs := newCallSet()

	numCalls := 10
	for i := 0; i < numCalls; i++ {
		cs.Add(newCall(t, receiver, method, reflect.TypeOf(receiverType{}.Func)))
	}

	call, err := cs.FindMatch(receiver, method, []interface{}{})
	if err != nil {
		t.Fatalf("FindMatch: %v", err)
	}
	if call == nil {
		t.Fatalf("FindMatch: Got nil, want non-nil *Call")
	}
}

func TestCallSetRemove(t *testing.T) {
	method := "TestMethod"
	var receiver interface{} = "TestReceiver"

	cs := newCallSet()
	ourCalls := []*Call{}

	numCalls := 10
	for i := 0; i < numCalls; i++ {
		// NOTE: abuse the `numCalls` value to convey initial ordering of mocked calls
		generatedCall := &Call{receiver: receiver, method: method, numCalls: i}
		cs.Add(generatedCall)
		ourCalls = append(ourCalls, generatedCall)
	}

	// validateOrder validates that the calls in the array are ordered as they were added
	validateOrder := func(calls []*Call) {
		// lastNum tracks the last `numCalls` (call order) value seen
		lastNum := -1
		for _, c := range calls {
			if lastNum >= c.numCalls {
				t.Errorf("found call %d after call %d", c.numCalls, lastNum)
			}
			lastNum = c.numCalls
		}
	}

	for _, c := range ourCalls {
		validateOrder(cs.expected[callSetKey{receiver, method}])
		cs.Remove(c)
	}
}

func TestCallSetFindMatch(t *testing.T) {
	t.Run("call is exhausted", func(t *testing.T) {
		cs := callSet{}
		var receiver interface{} = "TestReceiver"
		method := "TestMethod"
		args := []interface{}{}

		c1 := newCall(t, receiver, method, reflect.TypeOf(receiverType{}.Func))
		cs.exhausted = map[callSetKey][]*Call{
			{receiver: receiver, fname: method}: {c1},
		}

		_, err := cs.FindMatch(receiver, method, args)
		if err == nil {
			t.Fatal("expected error, but was nil")
		}

		if err.Error() == "" {
			t.Fatal("expected error to have message, but was empty")
		}
	})
}


================================================
FILE: gomock/controller.go
================================================
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package gomock

import (
	"context"
	"fmt"
	"reflect"
	"runtime"
	"sync"
)

// A TestReporter is something that can be used to report test failures.  It
// is satisfied by the standard library's *testing.T.
type TestReporter interface {
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
}

// TestHelper is a TestReporter that has the Helper method.  It is satisfied
// by the standard library's *testing.T.
type TestHelper interface {
	TestReporter
	Helper()
}

// cleanuper is used to check if TestHelper also has the `Cleanup` method. A
// common pattern is to pass in a `*testing.T` to
// `NewController(t TestReporter)`. In Go 1.14+, `*testing.T` has a cleanup
// method. This can be utilized to call `Finish()` so the caller of this library
// does not have to.
type cleanuper interface {
	Cleanup(func())
}

// A Controller represents the top-level control of a mock ecosystem.  It
// defines the scope and lifetime of mock objects, as well as their
// expectations.  It is safe to call Controller's methods from multiple
// goroutines. Each test should create a new Controller and invoke Finish via
// defer.
//
//   func TestFoo(t *testing.T) {
//     ctrl := gomock.NewController(t)
//     defer ctrl.Finish()
//     // ..
//   }
//
//   func TestBar(t *testing.T) {
//     t.Run("Sub-Test-1", st) {
//       ctrl := gomock.NewController(st)
//       defer ctrl.Finish()
//       // ..
//     })
//     t.Run("Sub-Test-2", st) {
//       ctrl := gomock.NewController(st)
//       defer ctrl.Finish()
//       // ..
//     })
//   })
type Controller struct {
	// T should only be called within a generated mock. It is not intended to
	// be used in user code and may be changed in future versions. T is the
	// TestReporter passed in when creating the Controller via NewController.
	// If the TestReporter does not implement a TestHelper it will be wrapped
	// with a nopTestHelper.
	T             TestHelper
	mu            sync.Mutex
	expectedCalls *callSet
	finished      bool
}

// NewController returns a new Controller. It is the preferred way to create a
// Controller.
//
// New in go1.14+, if you are passing a *testing.T into this function you no
// longer need to call ctrl.Finish() in your test methods.
func NewController(t TestReporter) *Controller {
	h, ok := t.(TestHelper)
	if !ok {
		h = &nopTestHelper{t}
	}
	ctrl := &Controller{
		T:             h,
		expectedCalls: newCallSet(),
	}
	if c, ok := isCleanuper(ctrl.T); ok {
		c.Cleanup(func() {
			ctrl.T.Helper()
			ctrl.finish(true, nil)
		})
	}

	return ctrl
}

type cancelReporter struct {
	t      TestHelper
	cancel func()
}

func (r *cancelReporter) Errorf(format string, args ...interface{}) {
	r.t.Errorf(format, args...)
}
func (r *cancelReporter) Fatalf(format string, args ...interface{}) {
	defer r.cancel()
	r.t.Fatalf(format, args...)
}

func (r *cancelReporter) Helper() {
	r.t.Helper()
}

// WithContext returns a new Controller and a Context, which is cancelled on any
// fatal failure.
func WithContext(ctx context.Context, t TestReporter) (*Controller, context.Context) {
	h, ok := t.(TestHelper)
	if !ok {
		h = &nopTestHelper{t: t}
	}

	ctx, cancel := context.WithCancel(ctx)
	return NewController(&cancelReporter{t: h, cancel: cancel}), ctx
}

type nopTestHelper struct {
	t TestReporter
}

func (h *nopTestHelper) Errorf(format string, args ...interface{}) {
	h.t.Errorf(format, args...)
}
func (h *nopTestHelper) Fatalf(format string, args ...interface{}) {
	h.t.Fatalf(format, args...)
}

func (h nopTestHelper) Helper() {}

// RecordCall is called by a mock. It should not be called by user code.
func (ctrl *Controller) RecordCall(receiver interface{}, method string, args ...interface{}) *Call {
	ctrl.T.Helper()

	recv := reflect.ValueOf(receiver)
	for i := 0; i < recv.Type().NumMethod(); i++ {
		if recv.Type().Method(i).Name == method {
			return ctrl.RecordCallWithMethodType(receiver, method, recv.Method(i).Type(), args...)
		}
	}
	ctrl.T.Fatalf("gomock: failed finding method %s on %T", method, receiver)
	panic("unreachable")
}

// RecordCallWithMethodType is called by a mock. It should not be called by user code.
func (ctrl *Controller) RecordCallWithMethodType(receiver interface{}, method string, methodType reflect.Type, args ...interface{}) *Call {
	ctrl.T.Helper()

	call := newCall(ctrl.T, receiver, method, methodType, args...)

	ctrl.mu.Lock()
	defer ctrl.mu.Unlock()
	ctrl.expectedCalls.Add(call)

	return call
}

// Call is called by a mock. It should not be called by user code.
func (ctrl *Controller) Call(receiver interface{}, method string, args ...interface{}) []interface{} {
	ctrl.T.Helper()

	// Nest this code so we can use defer to make sure the lock is released.
	actions := func() []func([]interface{}) []interface{} {
		ctrl.T.Helper()
		ctrl.mu.Lock()
		defer ctrl.mu.Unlock()

		expected, err := ctrl.expectedCalls.FindMatch(receiver, method, args)
		if err != nil {
			// callerInfo's skip should be updated if the number of calls between the user's test
			// and this line changes, i.e. this code is wrapped in another anonymous function.
			// 0 is us, 1 is controller.Call(), 2 is the generated mock, and 3 is the user's test.
			origin := callerInfo(3)
			ctrl.T.Fatalf("Unexpected call to %T.%v(%v) at %s because: %s", receiver, method, args, origin, err)
		}

		// Two things happen here:
		// * the matching call no longer needs to check prerequite calls,
		// * and the prerequite calls are no longer expected, so remove them.
		preReqCalls := expected.dropPrereqs()
		for _, preReqCall := range preReqCalls {
			ctrl.expectedCalls.Remove(preReqCall)
		}

		actions := expected.call()
		if expected.exhausted() {
			ctrl.expectedCalls.Remove(expected)
		}
		return actions
	}()

	var rets []interface{}
	for _, action := range actions {
		if r := action(args); r != nil {
			rets = r
		}
	}

	return rets
}

// Finish checks to see if all the methods that were expected to be called
// were called. It should be invoked for each Controller. It is not idempotent
// and therefore can only be invoked once.
//
// New in go1.14+, if you are passing a *testing.T into NewController function you no
// longer need to call ctrl.Finish() in your test methods.
func (ctrl *Controller) Finish() {
	// If we're currently panicking, probably because this is a deferred call.
	// This must be recovered in the deferred function.
	err := recover()
	ctrl.finish(false, err)
}

func (ctrl *Controller) finish(cleanup bool, panicErr interface{}) {
	ctrl.T.Helper()

	ctrl.mu.Lock()
	defer ctrl.mu.Unlock()

	if ctrl.finished {
		if _, ok := isCleanuper(ctrl.T); !ok {
			ctrl.T.Fatalf("Controller.Finish was called more than once. It has to be called exactly once.")
		}
		return
	}
	ctrl.finished = true

	// Short-circuit, pass through the panic.
	if panicErr != nil {
		panic(panicErr)
	}

	// Check that all remaining expected calls are satisfied.
	failures := ctrl.expectedCalls.Failures()
	for _, call := range failures {
		ctrl.T.Errorf("missing call(s) to %v", call)
	}
	if len(failures) != 0 {
		if !cleanup {
			ctrl.T.Fatalf("aborting test due to missing call(s)")
			return
		}
		ctrl.T.Errorf("aborting test due to missing call(s)")
	}
}

// callerInfo returns the file:line of the call site. skip is the number
// of stack frames to skip when reporting. 0 is callerInfo's call site.
func callerInfo(skip int) string {
	if _, file, line, ok := runtime.Caller(skip + 1); ok {
		return fmt.Sprintf("%s:%d", file, line)
	}
	return "unknown file"
}

// isCleanuper checks it if t's base TestReporter has a Cleanup method.
func isCleanuper(t TestReporter) (cleanuper, bool) {
	tr := unwrapTestReporter(t)
	c, ok := tr.(cleanuper)
	return c, ok
}

// unwrapTestReporter unwraps TestReporter to the base implementation.
func unwrapTestReporter(t TestReporter) TestReporter {
	tr := t
	switch nt := t.(type) {
	case *cancelReporter:
		tr = nt.t
		if h, check := tr.(*nopTestHelper); check {
			tr = h.t
		}
	case *nopTestHelper:
		tr = nt.t
	default:
		// not wrapped
	}
	return tr
}


================================================
FILE: gomock/controller_test.go
================================================
// Copyright 2011 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package gomock_test

import (
	"fmt"
	"reflect"
	"testing"

	"strings"

	"github.com/golang/mock/gomock"
)

type ErrorReporter struct {
	t          *testing.T
	log        []string
	failed     bool
	fatalToken struct{}
}

func NewErrorReporter(t *testing.T) *ErrorReporter {
	return &ErrorReporter{t: t}
}

func (e *ErrorReporter) reportLog() {
	for _, entry := range e.log {
		e.t.Log(entry)
	}
}

func (e *ErrorReporter) assertPass(msg string) {
	if e.failed {
		e.t.Errorf("Expected pass, but got failure(s): %s", msg)
		e.reportLog()
	}
}

func (e *ErrorReporter) assertFail(msg string) {
	if !e.failed {
		e.t.Errorf("Expected failure, but got pass: %s", msg)
	}
}

// Use to check that code triggers a fatal test failure.
func (e *ErrorReporter) assertFatal(fn func(), expectedErrMsgs ...string) {
	defer func() {
		err := recover()
		if err == nil {
			var actual string
			if e.failed {
				actual = "non-fatal failure"
			} else {
				actual = "pass"
			}
			e.t.Error("Expected fatal failure, but got a", actual)
		} else if token, ok := err.(*struct{}); ok && token == &e.fatalToken {
			// This is okay - the panic is from Fatalf().
			if expectedErrMsgs != nil {
				// assert that the actual error message
				// contains expectedErrMsgs

				// check the last actualErrMsg, because the previous messages come from previous errors
				actualErrMsg := e.log[len(e.log)-1]
				for _, expectedErrMsg := range expectedErrMsgs {
					if !strings.Contains(actualErrMsg, expectedErrMsg) {
						e.t.Errorf("Error message:\ngot: %q\nwant to contain: %q\n", actualErrMsg, expectedErrMsg)
					}
				}
			}
			return
		} else {
			// Some other panic.
			panic(err)
		}
	}()

	fn()
}

// recoverUnexpectedFatal can be used as a deferred call in test cases to
// recover from and display a call to ErrorReporter.Fatalf().
func (e *ErrorReporter) recoverUnexpectedFatal() {
	err := recover()
	if err == nil {
		// No panic.
	} else if token, ok := err.(*struct{}); ok && token == &e.fatalToken {
		// Unexpected fatal error happened.
		e.t.Error("Got unexpected fatal error(s). All errors up to this point:")
		e.reportLog()
		return
	} else {
		// Some other panic.
		panic(err)
	}
}

func (e *ErrorReporter) Log(args ...interface{}) {
	e.log = append(e.log, fmt.Sprint(args...))
}

func (e *ErrorReporter) Logf(format string, args ...interface{}) {
	e.log = append(e.log, fmt.Sprintf(format, args...))
}

func (e *ErrorReporter) Errorf(format string, args ...interface{}) {
	e.Logf(format, args...)
	e.failed = true
}

func (e *ErrorReporter) Fatalf(format string, args ...interface{}) {
	e.Logf(format, args...)
	e.failed = true
	panic(&e.fatalToken)
}

type HelperReporter struct {
	gomock.TestReporter
	helper int
}

func (h *HelperReporter) Helper() {
	h.helper++
}

// A type purely for use as a receiver in testing the Controller.
type Subject struct{}

func (s *Subject) FooMethod(arg string) int {
	return 0
}

func (s *Subject) BarMethod(arg string) int {
	return 0
}

func (s *Subject) VariadicMethod(arg int, vararg ...string) {}

// A type purely for ActOnTestStructMethod
type TestStruct struct {
	Number  int
	Message string
}

func (s *Subject) ActOnTestStructMethod(arg TestStruct, arg1 int) int {
	return 0
}

func (s *Subject) SetArgMethod(sliceArg []byte, ptrArg *int, mapArg map[interface{}]interface{}) {}
func (s *Subject) SetArgMethodInterface(sliceArg, ptrArg, mapArg interface{})                    {}

func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
	if !reflect.DeepEqual(expected, actual) {
		t.Errorf("Expected %+v, but got %+v", expected, actual)
	}
}

func createFixtures(t *testing.T) (reporter *ErrorReporter, ctrl *gomock.Controller) {
	// reporter acts as a testing.T-like object that we pass to the
	// Controller. We use it to test that the mock considered tests
	// successful or failed.
	reporter = NewErrorReporter(t)
	ctrl = gomock.NewController(reporter)
	return
}

func TestNoCalls(t *testing.T) {
	reporter, ctrl := createFixtures(t)
	ctrl.Finish()
	reporter.assertPass("No calls expected or made.")
}

func TestNoRecordedCallsForAReceiver(t *testing.T) {
	reporter, ctrl := createFixtures(t)
	subject := new(Subject)

	reporter.assertFatal(func() {
		ctrl.Call(subject, "NotRecordedMethod", "argument")
	}, "Unexpected call to", "there are no expected calls of the method \"NotRecordedMethod\" for that receiver")
	ctrl.Finish()
}

func TestNoRecordedMatchingMethodNameForAReceiver(t *testing.T) {
	reporter, ctrl := createFixtures(t)
	subject := new(Subject)

	ctrl.RecordCall(subject, "FooMethod", "argument")
	reporter.assertFatal(func() {
		ctrl.Call(subject, "NotRecordedMethod", "argument")
	}, "Unexpected call to", "there are no expected calls of the method \"NotRecordedMethod\" for that receiver")
	reporter.assertFatal(func() {
		// The expected call wasn't made.
		ctrl.Finish()
	})
}

// This tests that a call with an arguments of some primitive type matches a recorded call.
func TestExpectedMethodCall(t *testing.T) {
	reporter, ctrl := createFixtures(t)
	subject := new(Subject)

	ctrl.RecordCall(subject, "FooMethod", "argument")
	ctrl.Call(subject, "FooMethod", "argument")
	ctrl.Finish()

	reporter.assertPass("Expected method call made.")
}

func TestUnexpectedMethodCall(t *testing.T) {
	reporter, ctrl := createFixtures(t)
	subject := new(Subject)

	reporter.assertFatal(func() {
		ctrl.Call(subject, "FooMethod", "argument")
	})

	ctrl.Finish()
}

func TestRepeatedCall(t *testing.T) {
	reporter, ctrl := createFixtures(t)
	subject := new(Subject)

	ctrl.RecordCall(subject, "FooMethod", "argument").Times(3)
	ctrl.Call(subject, "FooMethod", "argument")
	ctrl.Call(subject, "FooMethod", "argument")
	ctrl.Call(subject, "FooMethod", "argument")
	reporter.assertPass("After expected repeated method calls.")
	reporter.assertFatal(func() {
		ctrl.Call(subject, "FooMethod", "argument")
	})
	ctrl.Finish()
	reporter.assertFail("After calling one too many times.")
}

func TestUnexpectedArgCount(t *testing.T) {
	reporter, ctrl := createFixtures(t)
	defer reporter.recoverUnexpectedFatal()
	subject := new(Subject)

	ctrl.RecordCall(subject, "FooMethod", "argument")
	reporter.assertFatal(func() {
		// This call is made with the wrong number of arguments...
		ctrl.Call(subject, "FooMethod", "argument", "extra_argument")
	}, "Unexpected call to", "wrong number of arguments", "Got: 2, want: 1")
	reporter.assertFatal(func() {
		// ... so is this.
		ctrl.Call(subject, "FooMethod")
	}, "Unexpected call to", "wrong number of arguments", "Got: 0, want: 1")
	reporter.assertFatal(func() {
		// The expected call wasn't made.
		ctrl.Finish()
	})
}

// This tests that a call with complex arguments (a struct and some primitive type) matches a recorded call.
func TestExpectedMethodCall_CustomStruct(t *testing.T) {
	reporter, ctrl := createFixtures(t)
	subject := new(Subject)

	expectedArg0 := TestStruct{Number: 123, Message: "hello"}
	ctrl.RecordCall(subject, "ActOnTestStructMethod", expectedArg0, 15)
	ctrl.Call(subject, "ActOnTestStructMethod", expectedArg0, 15)

	reporter.assertPass("Expected method call made.")
}

func TestUnexpectedArgValue_FirstArg(t *testing.T) {
	reporter, ctrl := createFixtures(t)
	defer reporter.recoverUnexpectedFatal()
	subject := new(Subject)

	expectedArg0 := TestStruct{Number: 123, Message: "hello %s"}
	ctrl.RecordCall(subject, "ActOnTestStructMethod", expectedArg0, 15)

	reporter.assertFatal(func() {
		// the method argument (of TestStruct type) has 1 unexpected value (for the Message field)
		ctrl.Call(subject, "ActOnTestStructMethod", TestStruct{Number: 123, Message: "no message"}, 15)
	}, "Unexpected call to", "doesn't match the argument at index 0",
		"Got: {123 no message} (gomock_test.TestStruct)\nWant: is equal to {123 hello %s} (gomock_test.TestStruct)")

	reporter.assertFatal(func() {
		// the method argument (of TestStruct type) has 2 unexpected values (for both fields)
		ctrl.Call(subject, "ActOnTestStructMethod", TestStruct{Number: 11, Message: "no message"}, 15)
	}, "Unexpected call to", "doesn't match the argument at index 0",
		"Got: {11 no message} (gomock_test.TestStruct)\nWant: is equal to {123 hello %s} (gomock_test.TestStruct)")

	reporter.assertFatal(func() {
		// The expected call wasn't made.
		ctrl.Finish()
	})
}

func TestUnexpectedArgValue_SecondArg(t *testing.T) {
	reporter, ctrl := createFixtures(t)
	defer reporter.recoverUnexpectedFatal()
	subject := new(Subject)

	expectedArg0 := TestStruct{Number: 123, Message: "hello"}
	ctrl.RecordCall(subject, "ActOnTestStructMethod", expectedArg0, 15)

	reporter.assertFatal(func() {
		ctrl.Call(subject, "ActOnTestStructMethod", TestStruct{Number: 123, Message: "hello"}, 3)
	}, "Unexpected call to", "doesn't match the argument at index 1",
		"Got: 3 (int)\nWant: is equal to 15 (int)")

	reporter.assertFatal(func() {
		// The expected call wasn't made.
		ctrl.Finish()
	})
}

func TestUnexpectedArgValue_WantFormatter(t *testing.T) {
	reporter, ctrl := createFixtures(t)
	defer reporter.recoverUnexpectedFatal()
	subject := new(Subject)

	expectedArg0 := TestStruct{Number: 123, Message: "hello"}
	ctrl.RecordCall(
		subject,
		"ActOnTestStructMethod",
		expectedArg0,
		gomock.WantFormatter(
			gomock.StringerFunc(func() string { return "is equal to fifteen" }),
			gomock.Eq(15),
		),
	)

	reporter.assertFatal(func() {
		ctrl.Call(subject, "ActOnTestStructMethod", TestStruct{Number: 123, Message: "hello"}, 3)
	}, "Unexpected call to", "doesn't match the argument at index 1",
		"Got: 3 (int)\nWant: is equal to fifteen")

	reporter.assertFatal(func() {
		// The expected call wasn't made.
		ctrl.Finish()
	})
}

func TestUnexpectedArgValue_GotFormatter(t *testing.T) {
	reporter, ctrl := createFixtures(t)
	defer reporter.recoverUnexpectedFatal()
	subject := new(Subject)

	expectedArg0 := TestStruct{Number: 123, Message: "hello"}
	ctrl.RecordCall(
		subject,
		"ActOnTestStructMethod",
		expectedArg0,
		gomock.GotFormatterAdapter(
			gomock.GotFormatterFunc(func(i interface{}) string {
				// Leading 0s
				return fmt.Sprintf("%02d", i)
			}),
			gomock.Eq(15),
		),
	)

	reporter.assertFatal(func() {
		ctrl.Call(subject, "ActOnTestStructMethod", TestStruct{Number: 123, Message: "hello"}, 3)
	}, "Unexpected call to", "doesn't match the argument at index 1",
		"Got: 03\nWant: is equal to 15")

	reporter.assertFatal(func() {
		// The expected call wasn't made.
		ctrl.Finish()
	})
}

func TestAnyTimes(t *testing.T) {
	reporter, ctrl := createFixtures(t)
	subject := new(Subject)

	ctrl.RecordCall(subject, "FooMethod", "argument").AnyTimes()
	for i := 0; i < 100; i++ {
		ctrl.Call(subject, "FooMethod", "argument")
	}
	reporter.assertPass("After 100 method calls.")
	ctrl.Finish()
}

func TestMinTimes1(t *testing.T) {
	// It fails if there are no calls
	reporter, ctrl := createFixtures(t)
	subject := new(Subject)
	ctrl.RecordCall(subject, "FooMethod", "argument").MinTimes(1)
	reporter.assertFatal(func() {
		ctrl.Finish()
	})

	// It succeeds if there is one call
	_, ctrl = createFixtures(t)
	subject = new(Subject)
	ctrl.RecordCall(subject, "FooMethod", "argument").MinTimes(1)
	ctrl.Call(subject, "FooMethod", "argument")
	ctrl.Finish()

	// It succeeds if there are many calls
	_, ctrl = createFixtures(t)
	subject = new(Subject)
	ctrl.RecordCall(subject, "FooMethod", "argument").MinTimes(1)
	for i := 0; i < 100; i++ {
		ctrl.Call(subject, "FooMethod", "argument")
	}
	ctrl.Finish()
}

func TestMaxTimes1(t *testing.T) {
	// It succeeds if there are no calls
	_, ctrl := createFixtures(t)
	subject := new(Subject)
	ctrl.RecordCall(subject, "FooMethod", "argument").MaxTimes(1)
	ctrl.Finish()

	// It succeeds if there is one call
	_, ctrl = createFixtures(t)
	subject = new(Subject)
	ctrl.RecordCall(subject, "FooMethod", "argument").MaxTimes(1)
	ctrl.Call(subject, "FooMethod", "argument")
	ctrl.Finish()

	// It fails if there are more
	reporter, ctrl := createFixtures(t)
	subject = new(Subject)
	ctrl.RecordCall(subject, "FooMethod", "argument").MaxTimes(1)
	ctrl.Call(subject, "FooMethod", "argument")
	reporter.assertFatal(func() {
		ctrl.Call(subject, "FooMethod", "argument")
	})
	ctrl.Finish()
}

func TestMinMaxTimes(t *testing.T) {
	// It fails if there are less calls than specified
	reporter, ctrl := createFixtures(t)
	subject := new(Subject)
	ctrl.RecordCall(subject, "FooMethod", "argument").MinTimes(2).MaxTimes(2)
	ctrl.Call(subject, "FooMethod", "argument")
	reporter.assertFatal(func() {
		ctrl.Finish()
	})

	// It fails if there are more calls than specified
	reporter, ctrl = createFixtures(t)
	subject = new(Subject)
	ctrl.RecordCall(subject, "FooMethod", "argument").MinTimes(2).MaxTimes(2)
	ctrl.Call(subject, "FooMethod", "argument")
	ctrl.Call(subject, "FooMethod", "argument")
	reporter.assertFatal(func() {
		ctrl.Call(subject, "FooMethod", "argument")
	})

	// It succeeds if there is just the right number of calls
	_, ctrl = createFixtures(t)
	subject = new(Subject)
	ctrl.RecordCall(subject, "FooMethod", "argument").MaxTimes(2).MinTimes(2)
	ctrl.Call(subject, "FooMethod", "argument")
	ctrl.Call(subject, "FooMethod", "argument")
	ctrl.Finish()

	// If MaxTimes is called after MinTimes is called with 1, MaxTimes takes precedence.
	reporter, ctrl = createFixtures(t)
	subject = new(Subject)
	ctrl.RecordCall(subject, "FooMethod", "argument").MinTimes(1).MaxTimes(2)
	ctrl.Call(subject, "FooMethod", "argument")
	ctrl.Call(subject, "FooMethod", "argument")
	reporter.assertFatal(func() {
		ctrl.Call(subject, "FooMethod", "argument")
	})

	// If MinTimes is called after MaxTimes is called with 1, MinTimes takes precedence.
	_, ctrl = createFixtures(t)
	subject = new(Subject)
	ctrl.RecordCall(subject, "FooMethod", "argument").MaxTimes(1).MinTimes(2)
	for i := 0; i < 100; i++ {
		ctrl.Call(subject, "FooMethod", "argument")
	}
	ctrl.Finish()
}

func TestDo(t *testing.T) {
	_, ctrl := createFixtures(t)
	subject := new(Subject)

	doCalled := false
	var argument string
	wantArg := "argument"
	ctrl.RecordCall(subject, "FooMethod", wantArg).Do(
		func(arg string) {
			doCalled = true
			argument = arg
		})
	if doCalled {
		t.Error("Do() callback called too early.")
	}

	ctrl.Call(subject, "FooMethod", wantArg)

	if !doCalled {
		t.Error("Do() callback not called.")
	}
	if wantArg != argument {
		t.Error("Do callback received wrong argument.")
	}

	ctrl.Finish()
}

func TestDoAndReturn(t *testing.T) {
	_, ctrl := createFixtures(t)
	subject := new(Subject)

	doCalled := false
	var argument string
	wantArg := "argument"
	ctrl.RecordCall(subject, "FooMethod", wantArg).DoAndReturn(
		func(arg string) int {
			doCalled = true
			argument = arg
			return 5
		})
	if doCalled {
		t.Error("Do() callback called too early.")
	}

	rets := ctrl.Call(subject, "FooMethod", wantArg)

	if !doCalled {
		t.Error("Do() callback not called.")
	}
	if wantArg != argument {
		t.Error("Do callback received wrong argument.")
	}
	if len(rets) != 1 {
		t.Fatalf("Return values from Call: got %d, want 1", len(rets))
	}
	if ret, ok := rets[0].(int); !ok {
		t.Fatalf("Return value is not an int")
	} else if ret != 5 {
		t.Errorf("DoAndReturn return value: got %d, want 5", ret)
	}

	ctrl.Finish()
}

func TestSetArgSlice(t *testing.T) {
	_, ctrl := createFixtures(t)
	subject := new(Subject)

	var in = []byte{4, 5, 6}
	var set = []byte{1, 2, 3}
	ctrl.RecordCall(subject, "SetArgMethod", in, nil, nil).SetArg(0, set)
	ctrl.Call(subject, "SetArgMethod", in, nil, nil)

	if !reflect.DeepEqual(in, set) {
		t.Error("Expected SetArg() to modify input slice argument")
	}

	ctrl.RecordCall(subject, "SetArgMethodInterface", in, nil, nil).SetArg(0, set)
	ctrl.Call(subject, "SetArgMethodInterface", in, nil, nil)

	if !reflect.DeepEqual(in, set) {
		t.Error("Expected SetArg() to modify input slice argument as interface{}")
	}

	ctrl.Finish()
}

func TestSetArgMap(t *testing.T) {
	_, ctrl := createFixtures(t)
	subject := new(Subject)

	var in = map[interface{}]interface{}{"int": 1, "string": "random string", 1: "1", 0: 0}
	var set = map[interface{}]interface{}{"int": 2, 1: "2", 2: 100}
	ctrl.RecordCall(subject, "SetArgMethod", nil, nil, in).SetArg(2, set)
	ctrl.Call(subject, "SetArgMethod", nil, nil, in)

	if !reflect.DeepEqual(in, set) {
		t.Error("Expected SetArg() to modify input map argument")
	}

	ctrl.RecordCall(subject, "SetArgMethodInterface", nil, nil, in).SetArg(2, set)
	ctrl.Call(subject, "SetArgMethodInterface", nil, nil, in)

	if !reflect.DeepEqual(in, set) {
		t.Error("Expected SetArg() to modify input map argument as interface{}")
	}

	ctrl.Finish()
}

func TestSetArgPtr(t *testing.T) {
	_, ctrl := createFixtures(t)
	subject := new(Subject)

	var in int = 43
	const set = 42
	ctrl.RecordCall(subject, "SetArgMethod", nil, &in, nil).SetArg(1, set)
	ctrl.Call(subject, "SetArgMethod", nil, &in, nil)

	if in != set {
		t.Error("Expected SetArg() to modify value pointed to by argument")
	}

	ctrl.RecordCall(subject, "SetArgMethodInterface", nil, &in, nil).SetArg(1, set)
	ctrl.Call(subject, "SetArgMethodInterface", nil, &in, nil)

	if in != set {
		t.Error("Expected SetArg() to modify value pointed to by argument as interface{}")
	}
	ctrl.Finish()
}

func TestReturn(t *testing.T) {
	_, ctrl := createFixtures(t)
	subject := new(Subject)

	// Unspecified return should produce "zero" result.
	ctrl.RecordCall(subject, "FooMethod", "zero")
	ctrl.RecordCall(subject, "FooMethod", "five").Return(5)

	assertEqual(
		t,
		[]interface{}{0},
		ctrl.Call(subject, "FooMethod", "zero"))

	assertEqual(
		t,
		[]interface{}{5},
		ctrl.Call(subject, "FooMethod", "five"))
	ctrl.Finish()
}

func TestUnorderedCalls(t *testing.T) {
	reporter, ctrl := createFixtures(t)
	defer reporter.recoverUnexpectedFatal()
	subjectTwo := new(Subject)
	subjectOne := new(Subject)

	ctrl.RecordCall(subjectOne, "FooMethod", "1")
	ctrl.RecordCall(subjectOne, "BarMethod", "2")
	ctrl.RecordCall(subjectTwo, "FooMethod", "3")
	ctrl.RecordCall(subjectTwo, "BarMethod", "4")

	// Make the calls in a different order, which should be fine.
	ctrl.Call(subjectOne, "BarMethod", "2")
	ctrl.Call(subjectTwo, "FooMethod", "3")
	ctrl.Call(subjectTwo, "BarMethod", "4")
	ctrl.Call(subjectOne, "FooMethod", "1")

	reporter.assertPass("After making all calls in different order")

	ctrl.Finish()

	reporter.assertPass("After finish")
}

func commonTestOrderedCalls(t *testing.T) (reporter *ErrorReporter, ctrl *gomock.Controller, subjectOne, subjectTwo *Subject) {
	reporter, ctrl = createFixtures(t)

	subjectOne = new(Subject)
	subjectTwo = new(Subject)

	gomock.InOrder(
		ctrl.RecordCall(subjectOne, "FooMethod", "1").AnyTimes(),
		ctrl.RecordCall(subjectTwo, "FooMethod", "2"),
		ctrl.RecordCall(subjectTwo, "BarMethod", "3"),
	)

	return
}

func TestOrderedCallsCorrect(t *testing.T) {
	reporter, ctrl, subjectOne, subjectTwo := commonTestOrderedCalls(t)

	ctrl.Call(subjectOne, "FooMethod", "1")
	ctrl.Call(subjectTwo, "FooMethod", "2")
	ctrl.Call(subjectTwo, "BarMethod", "3")

	ctrl.Finish()

	reporter.assertPass("After finish")
}

func TestPanicOverridesExpectationChecks(t *testing.T) {
	ctrl := gomock.NewController(t)
	reporter := NewErrorReporter(t)

	reporter.assertFatal(func() {
		ctrl.RecordCall(new(Subject), "FooMethod", "1")
		defer ctrl.Finish()
		reporter.Fatalf("Intentional panic")
	})
}

func TestSetArgWithBadType(t *testing.T) {
	rep, ctrl := createFixtures(t)
	defer ctrl.Finish()

	s := new(Subject)
	// This should catch a type error:
	rep.assertFatal(func() {
		ctrl.RecordCall(s, "FooMethod", "1").SetArg(0, "blah")
	})
	ctrl.Call(s, "FooMethod", "1")
}

func TestTimes0(t *testing.T) {
	rep, ctrl := createFixtures(t)
	defer ctrl.Finish()

	s := new(Subject)
	ctrl.RecordCall(s, "FooMethod", "arg").Times(0)
	rep.assertFatal(func() {
		ctrl.Call(s, "FooMethod", "arg")
	})
}

func TestVariadicMatching(t *testing.T) {
	rep, ctrl := createFixtures(t)
	defer rep.recoverUnexpectedFatal()

	s := new(Subject)
	ctrl.RecordCall(s, "VariadicMethod", 0, "1", "2")
	ctrl.Call(s, "VariadicMethod", 0, "1", "2")
	ctrl.Finish()
	rep.assertPass("variadic matching works")
}

func TestVariadicNoMatch(t *testing.T) {
	rep, ctrl := createFixtures(t)
	defer rep.recoverUnexpectedFatal()

	s := new(Subject)
	ctrl.RecordCall(s, "VariadicMethod", 0)
	rep.assertFatal(func() {
		ctrl.Call(s, "VariadicMethod", 1)
	}, "expected call at", "doesn't match the argument at index 0",
		"Got: 1 (int)\nWant: is equal to 0 (int)")
	ctrl.Call(s, "VariadicMethod", 0)
	ctrl.Finish()
}

func TestVariadicMatchingWithSlice(t *testing.T) {
	testCases := [][]string{
		{"1"},
		{"1", "2"},
	}
	for _, tc := range testCases {
		t.Run(fmt.Sprintf("%d arguments", len(tc)), func(t *testing.T) {
			rep, ctrl := createFixtures(t)
			defer rep.recoverUnexpectedFatal()

			s := new(Subject)
			ctrl.RecordCall(s, "VariadicMethod", 1, tc)
			args := make([]interface{}, len(tc)+1)
			args[0] = 1
			for i, arg := range tc {
				args[i+1] = arg
			}
			ctrl.Call(s, "VariadicMethod", args...)
			ctrl.Finish()
			rep.assertPass("slices can be used as matchers for variadic arguments")
		})
	}
}

func TestVariadicArgumentsGotFormatter(t *testing.T) {
	rep, ctrl := createFixtures(t)
	defer rep.recoverUnexpectedFatal()

	s := new(Subject)
	ctrl.RecordCall(
		s,
		"VariadicMethod",
		gomock.GotFormatterAdapter(
			gomock.GotFormatterFunc(func(i interface{}) string {
				return fmt.Sprintf("test{%v}", i)
			}),
			gomock.Eq(0),
		),
	)

	rep.assertFatal(func() {
		ctrl.Call(s, "VariadicMethod", 1)
	}, "expected call to", "doesn't match the argument at index 0",
		"Got: test{1}\nWant: is equal to 0")
	ctrl.Call(s, "VariadicMethod", 0)
	ctrl.Finish()
}

func TestVariadicArgumentsGotFormatterTooManyArgsFailure(t *testing.T) {
	rep, ctrl := createFixtures(t)
	defer rep.recoverUnexpectedFatal()

	s := new(Subject)
	ctrl.RecordCall(
		s,
		"VariadicMethod",
		0,
		gomock.GotFormatterAdapter(
			gomock.GotFormatterFunc(func(i interface{}) string {
				return fmt.Sprintf("test{%v}", i)
			}),
			gomock.Eq("1"),
		),
	)

	rep.assertFatal(func() {
		ctrl.Call(s, "VariadicMethod", 0, "2", "3")
	}, "expected call to", "doesn't match the argument at index 1",
		"Got: test{[2 3]}\nWant: is equal to 1")
	ctrl.Call(s, "VariadicMethod", 0, "1")
	ctrl.Finish()
}

func TestNoHelper(t *testing.T) {
	ctrlNoHelper := gomock.NewController(NewErrorReporter(t))

	// doesn't panic
	ctrlNoHelper.T.Helper()
}

func TestWithHelper(t *testing.T) {
	withHelper := &HelperReporter{TestReporter: NewErrorReporter(t)}
	ctrlWithHelper := gomock.NewController(withHelper)

	ctrlWithHelper.T.Helper()

	if withHelper.helper == 0 {
		t.Fatal("expected Helper to be invoked")
	}
}

func (e *ErrorReporter) Cleanup(f func()) {
	e.t.Helper()
	e.t.Cleanup(f)
}

func TestMultipleDefers(t *testing.T) {
	reporter := NewErrorReporter(t)
	reporter.Cleanup(func() {
		reporter.assertPass("No errors for multiple calls to Finish")
	})
	ctrl := gomock.NewController(reporter)
	ctrl.Finish()
}

// Equivalent to the TestNoRecordedCallsForAReceiver, but without explicitly
// calling Finish.
func TestDeferNotNeededFail(t *testing.T) {
	reporter := NewErrorReporter(t)
	subject := new(Subject)
	var ctrl *gomock.Controller
	reporter.Cleanup(func() {
		reporter.assertFatal(func() {
			ctrl.Call(subject, "NotRecordedMethod", "argument")
		}, "Unexpected call to", "there are no expected calls of the method \"NotRecordedMethod\" for that receiver")
	})
	ctrl = gomock.NewController(reporter)
}

func TestDeferNotNeededPass(t *testing.T) {
	reporter := NewErrorReporter(t)
	subject := new(Subject)
	var ctrl *gomock.Controller
	reporter.Cleanup(func() {
		reporter.assertPass("Expected method call made.")
	})
	ctrl = gomock.NewController(reporter)
	ctrl.RecordCall(subject, "FooMethod", "argument")
	ctrl.Call(subject, "FooMethod", "argument")
}

func TestOrderedCallsInCorrect(t *testing.T) {
	reporter := NewErrorReporter(t)
	subjectOne := new(Subject)
	subjectTwo := new(Subject)
	var ctrl *gomock.Controller
	reporter.Cleanup(func() {
		reporter.assertFatal(func() {
			gomock.InOrder(
				ctrl.RecordCall(subjectOne, "FooMethod", "1").AnyTimes(),
				ctrl.RecordCall(subjectTwo, "FooMethod", "2"),
				ctrl.RecordCall(subjectTwo, "BarMethod", "3"),
			)
			ctrl.Call(subjectOne, "FooMethod", "1")
			// FooMethod(2) should be called before BarMethod(3)
			ctrl.Call(subjectTwo, "BarMethod", "3")
		}, "Unexpected call to", "Subject.BarMethod([3])", "doesn't have a prerequisite call satisfied")
	})
	ctrl = gomock.NewController(reporter)
}

// Test that calls that are prerequisites to other calls but have maxCalls >
// minCalls are removed from the expected call set.
func TestOrderedCallsWithPreReqMaxUnbounded(t *testing.T) {
	reporter := NewErrorReporter(t)
	subjectOne := new(Subject)
	subjectTwo := new(Subject)
	var ctrl *gomock.Controller
	reporter.Cleanup(func() {
		reporter.assertFatal(func() {
			// Initially we should be able to call FooMethod("1") as many times as we
			// want.
			ctrl.Call(subjectOne, "FooMethod", "1")
			ctrl.Call(subjectOne, "FooMethod", "1")

			// But calling something that has it as a prerequite should remove it from
			// the expected call set. This allows tests to ensure that FooMethod("1") is
			// *not* called after FooMethod("2").
			ctrl.Call(subjectTwo, "FooMethod", "2")

			ctrl.Call(subjectOne, "FooMethod", "1")
		})
	})
	ctrl = gomock.NewController(reporter)
}

func TestCallAfterLoopPanic(t *testing.T) {
	reporter := NewErrorReporter(t)
	subject := new(Subject)
	var ctrl *gomock.Controller
	reporter.Cleanup(func() {
		firstCall := ctrl.RecordCall(subject, "FooMethod", "1")
		secondCall := ctrl.RecordCall(subject, "FooMethod", "2")
		thirdCall := ctrl.RecordCall(subject, "FooMethod", "3")

		gomock.InOrder(firstCall, secondCall, thirdCall)

		defer func() {
			err := recover()
			if err == nil {
				t.Error("Call.After creation of dependency loop did not panic.")
			}
		}()

		// This should panic due to dependency loop.
		firstCall.After(thirdCall)
	})
	ctrl = gomock.NewController(reporter)
}


================================================
FILE: gomock/doc.go
================================================
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package gomock is a mock framework for Go.
//
// Standard usage:
//   (1) Define an interface that you wish to mock.
//         type MyInterface interface {
//           SomeMethod(x int64, y string)
//         }
//   (2) Use mockgen to generate a mock from the interface.
//   (3) Use the mock in a test:
//         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.
//         }
//
// By default, expected calls are not enforced to run in any particular order.
// Call order dependency can be enforced by use of InOrder and/or Call.After.
// Call.After can create more varied call order dependencies, but InOrder is
// often more convenient.
//
// The following examples create equivalent call order dependencies.
//
// Example of using Call.After to chain expected call order:
//
//     firstCall := mockObj.EXPECT().SomeMethod(1, "first")
//     secondCall := mockObj.EXPECT().SomeMethod(2, "second").After(firstCall)
//     mockObj.EXPECT().SomeMethod(3, "third").After(secondCall)
//
// Example of using InOrder to declare expected call order:
//
//     gomock.InOrder(
//         mockObj.EXPECT().SomeMethod(1, "first"),
//         mockObj.EXPECT().SomeMethod(2, "second"),
//         mockObj.EXPECT().SomeMethod(3, "third"),
//     )
//
// The standard TestReporter most users will pass to `NewController` is a
// `*testing.T` from the context of the test. Note that this will use the
// standard `t.Error` and `t.Fatal` methods to report what happened in the test.
// In some cases this can leave your testing package in a weird state if global
// state is used since `t.Fatal` is like calling panic in the middle of a
// function. In these cases it is recommended that you pass in your own
// `TestReporter`.
package gomock


================================================
FILE: gomock/example_test.go
================================================
package gomock_test

//go:generate mockgen -destination mock_test.go -package gomock_test -source example_test.go

import (
	"fmt"
	"testing"
	"time"

	"github.com/golang/mock/gomock"
)

type Foo interface {
	Bar(string) string
}

func ExampleCall_DoAndReturn_latency() {
	t := &testing.T{} // provided by test
	ctrl := gomock.NewController(t)
	mockIndex := NewMockFoo(ctrl)

	mockIndex.EXPECT().Bar(gomock.Any()).DoAndReturn(
		func(arg string) string {
			time.Sleep(1 * time.Millisecond)
			return "I'm sleepy"
		},
	)

	r := mockIndex.Bar("foo")
	fmt.Println(r)
	// Output: I'm sleepy
}

func ExampleCall_DoAndReturn_captureArguments() {
	t := &testing.T{} // provided by test
	ctrl := gomock.NewController(t)
	mockIndex := NewMockFoo(ctrl)
	var s string

	mockIndex.EXPECT().Bar(gomock.AssignableToTypeOf(s)).DoAndReturn(
		func(arg string) interface{} {
			s = arg
			return "I'm sleepy"
		},
	)

	r := mockIndex.Bar("foo")
	fmt.Printf("%s %s", r, s)
	// Output: I'm sleepy foo
}


================================================
FILE: gomock/internal/mock_gomock/mock_matcher.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/golang/mock/gomock (interfaces: Matcher)

// Package mock_gomock is a generated GoMock package.
package mock_gomock

import (
	reflect "reflect"

	gomock "github.com/golang/mock/gomock"
)

// MockMatcher is a mock of Matcher interface.
type MockMatcher struct {
	ctrl     *gomock.Controller
	recorder *MockMatcherMockRecorder
}

// MockMatcherMockRecorder is the mock recorder for MockMatcher.
type MockMatcherMockRecorder struct {
	mock *MockMatcher
}

// NewMockMatcher creates a new mock instance.
func NewMockMatcher(ctrl *gomock.Controller) *MockMatcher {
	mock := &MockMatcher{ctrl: ctrl}
	mock.recorder = &MockMatcherMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockMatcher) EXPECT() *MockMatcherMockRecorder {
	return m.recorder
}

// Matches mocks base method.
func (m *MockMatcher) Matches(arg0 interface{}) bool {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Matches", arg0)
	ret0, _ := ret[0].(bool)
	return ret0
}

// Matches indicates an expected call of Matches.
func (mr *MockMatcherMockRecorder) Matches(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Matches", reflect.TypeOf((*MockMatcher)(nil).Matches), arg0)
}

// String mocks base method.
func (m *MockMatcher) String() string {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "String")
	ret0, _ := ret[0].(string)
	return ret0
}

// String indicates an expected call of String.
func (mr *MockMatcherMockRecorder) String() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "String", reflect.TypeOf((*MockMatcher)(nil).String))
}


================================================
FILE: gomock/matchers.go
================================================
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package gomock

import (
	"fmt"
	"reflect"
	"strings"
)

// A Matcher is a representation of a class of values.
// It is used to represent the valid or expected arguments to a mocked method.
type Matcher interface {
	// Matches returns whether x is a match.
	Matches(x interface{}) bool

	// String describes what the matcher matches.
	String() string
}

// WantFormatter modifies the given Matcher's String() method to the given
// Stringer. This allows for control on how the "Want" is formatted when
// printing .
func WantFormatter(s fmt.Stringer, m Matcher) Matcher {
	type matcher interface {
		Matches(x interface{}) bool
	}

	return struct {
		matcher
		fmt.Stringer
	}{
		matcher:  m,
		Stringer: s,
	}
}

// StringerFunc type is an adapter to allow the use of ordinary functions as
// a Stringer. If f is a function with the appropriate signature,
// StringerFunc(f) is a Stringer that calls f.
type StringerFunc func() string

// String implements fmt.Stringer.
func (f StringerFunc) String() string {
	return f()
}

// GotFormatter is used to better print failure messages. If a matcher
// implements GotFormatter, it will use the result from Got when printing
// the failure message.
type GotFormatter interface {
	// Got is invoked with the received value. The result is used when
	// printing the failure message.
	Got(got interface{}) string
}

// GotFormatterFunc type is an adapter to allow the use of ordinary
// functions as a GotFormatter. If f is a function with the appropriate
// signature, GotFormatterFunc(f) is a GotFormatter that calls f.
type GotFormatterFunc func(got interface{}) string

// Got implements GotFormatter.
func (f GotFormatterFunc) Got(got interface{}) string {
	return f(got)
}

// GotFormatterAdapter attaches a GotFormatter to a Matcher.
func GotFormatterAdapter(s GotFormatter, m Matcher) Matcher {
	return struct {
		GotFormatter
		Matcher
	}{
		GotFormatter: s,
		Matcher:      m,
	}
}

type anyMatcher struct{}

func (anyMatcher) Matches(interface{}) bool {
	return true
}

func (anyMatcher) String() string {
	return "is anything"
}

type eqMatcher struct {
	x interface{}
}

func (e eqMatcher) Matches(x interface{}) bool {
	// In case, some value is nil
	if e.x == nil || x == nil {
		return reflect.DeepEqual(e.x, x)
	}

	// Check if types assignable and convert them to common type
	x1Val := reflect.ValueOf(e.x)
	x2Val := reflect.ValueOf(x)

	if x1Val.Type().AssignableTo(x2Val.Type()) {
		x1ValConverted := x1Val.Convert(x2Val.Type())
		return reflect.DeepEqual(x1ValConverted.Interface(), x2Val.Interface())
	}

	return false
}

func (e eqMatcher) String() string {
	return fmt.Sprintf("is equal to %v (%T)", e.x, e.x)
}

type nilMatcher struct{}

func (nilMatcher) Matches(x interface{}) bool {
	if x == nil {
		return true
	}

	v := reflect.ValueOf(x)
	switch v.Kind() {
	case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map,
		reflect.Ptr, reflect.Slice:
		return v.IsNil()
	}

	return false
}

func (nilMatcher) String() string {
	return "is nil"
}

type notMatcher struct {
	m Matcher
}

func (n notMatcher) Matches(x interface{}) bool {
	return !n.m.Matches(x)
}

func (n notMatcher) String() string {
	return "not(" + n.m.String() + ")"
}

type assignableToTypeOfMatcher struct {
	targetType reflect.Type
}

func (m assignableToTypeOfMatcher) Matches(x interface{}) bool {
	return reflect.TypeOf(x).AssignableTo(m.targetType)
}

func (m assignableToTypeOfMatcher) String() string {
	return "is assignable to " + m.targetType.Name()
}

type allMatcher struct {
	matchers []Matcher
}

func (am allMatcher) Matches(x interface{}) bool {
	for _, m := range am.matchers {
		if !m.Matches(x) {
			return false
		}
	}
	return true
}

func (am allMatcher) String() string {
	ss := make([]string, 0, len(am.matchers))
	for _, matcher := range am.matchers {
		ss = append(ss, matcher.String())
	}
	return strings.Join(ss, "; ")
}

type lenMatcher struct {
	i int
}

func (m lenMatcher) Matches(x interface{}) bool {
	v := reflect.ValueOf(x)
	switch v.Kind() {
	case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice, reflect.String:
		return v.Len() == m.i
	default:
		return false
	}
}

func (m lenMatcher) String() string {
	return fmt.Sprintf("has length %d", m.i)
}

type inAnyOrderMatcher struct {
	x interface{}
}

func (m inAnyOrderMatcher) Matches(x interface{}) bool {
	given, ok := m.prepareValue(x)
	if !ok {
		return false
	}
	wanted, ok := m.prepareValue(m.x)
	if !ok {
		return false
	}

	if given.Len() != wanted.Len() {
		return false
	}

	usedFromGiven := make([]bool, given.Len())
	foundFromWanted := make([]bool, wanted.Len())
	for i := 0; i < wanted.Len(); i++ {
		wantedMatcher := Eq(wanted.Index(i).Interface())
		for j := 0; j < given.Len(); j++ {
			if usedFromGiven[j] {
				continue
			}
			if wantedMatcher.Matches(given.Index(j).Interface()) {
				foundFromWanted[i] = true
				usedFromGiven[j] = true
				break
			}
		}
	}

	missingFromWanted := 0
	for _, found := range foundFromWanted {
		if !found {
			missingFromWanted++
		}
	}
	extraInGiven := 0
	for _, used := range usedFromGiven {
		if !used {
			extraInGiven++
		}
	}

	return extraInGiven == 0 && missingFromWanted == 0
}

func (m inAnyOrderMatcher) prepareValue(x interface{}) (reflect.Value, bool) {
	xValue := reflect.ValueOf(x)
	switch xValue.Kind() {
	case reflect.Slice, reflect.Array:
		return xValue, true
	default:
		return reflect.Value{}, false
	}
}

func (m inAnyOrderMatcher) String() string {
	return fmt.Sprintf("has the same elements as %v", m.x)
}

// Constructors

// All returns a composite Matcher that returns true if and only all of the
// matchers return true.
func All(ms ...Matcher) Matcher { return allMatcher{ms} }

// Any returns a matcher that always matches.
func Any() Matcher { return anyMatcher{} }

// Eq returns a matcher that matches on equality.
//
// Example usage:
//   Eq(5).Matches(5) // returns true
//   Eq(5).Matches(4) // returns false
func Eq(x interface{}) Matcher { return eqMatcher{x} }

// Len returns a matcher that matches on length. This matcher returns false if
// is compared to a type that is not an array, chan, map, slice, or string.
func Len(i int) Matcher {
	return lenMatcher{i}
}

// Nil returns a matcher that matches if the received value is nil.
//
// Example usage:
//   var x *bytes.Buffer
//   Nil().Matches(x) // returns true
//   x = &bytes.Buffer{}
//   Nil().Matches(x) // returns false
func Nil() Matcher { return nilMatcher{} }

// Not reverses the results of its given child matcher.
//
// Example usage:
//   Not(Eq(5)).Matches(4) // returns true
//   Not(Eq(5)).Matches(5) // returns false
func Not(x interface{}) Matcher {
	if m, ok := x.(Matcher); ok {
		return notMatcher{m}
	}
	return notMatcher{Eq(x)}
}

// AssignableToTypeOf is a Matcher that matches if the parameter to the mock
// function is assignable to the type of the parameter to this function.
//
// Example usage:
//   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
func AssignableToTypeOf(x interface{}) Matcher {
	if xt, ok := x.(reflect.Type); ok {
		return assignableToTypeOfMatcher{xt}
	}
	return assignableToTypeOfMatcher{reflect.TypeOf(x)}
}

// InAnyOrder is a Matcher that returns true for collections of the same elements ignoring the order.
//
// Example usage:
//   InAnyOrder([]int{1, 2, 3}).Matches([]int{1, 3, 2}) // returns true
//   InAnyOrder([]int{1, 2, 3}).Matches([]int{1, 2}) // returns false
func InAnyOrder(x interface{}) Matcher {
	return inAnyOrderMatcher{x}
}


================================================
FILE: gomock/matchers_test.go
================================================
// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package gomock_test

//go:generate mockgen -destination internal/mock_gomock/mock_matcher.go github.com/golang/mock/gomock Matcher

import (
	"context"
	"errors"
	"reflect"
	"testing"

	"github.com/golang/mock/gomock"
	"github.com/golang/mock/gomock/internal/mock_gomock"
)

type A []string

func TestMatchers(t *testing.T) {
	type e interface{}
	tests := []struct {
		name    string
		matcher gomock.Matcher
		yes, no []e
	}{
		{"test Any", gomock.Any(), []e{3, nil, "foo"}, nil},
		{"test All", gomock.Eq(4), []e{4}, []e{3, "blah", nil, int64(4)}},
		{"test Nil", gomock.Nil(),
			[]e{nil, (error)(nil), (chan bool)(nil), (*int)(nil)},
			[]e{"", 0, make(chan bool), errors.New("err"), new(int)}},
		{"test Not", gomock.Not(gomock.Eq(4)), []e{3, "blah", nil, int64(4)}, []e{4}},
		{"test All", gomock.All(gomock.Any(), gomock.Eq(4)), []e{4}, []e{3, "blah", nil, int64(4)}},
		{"test Len", gomock.Len(2),
			[]e{[]int{1, 2}, "ab", map[string]int{"a": 0, "b": 1}, [2]string{"a", "b"}},
			[]e{[]int{1}, "a", 42, 42.0, false, [1]string{"a"}},
		},
		{"test assignable types", gomock.Eq(A{"a", "b"}),
			[]e{[]string{"a", "b"}, A{"a", "b"}},
			[]e{[]string{"a"}, A{"b"}},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			for _, x := range tt.yes {
				if !tt.matcher.Matches(x) {
					t.Errorf(`"%v %s": got false, want true.`, x, tt.matcher)
				}
			}
			for _, x := range tt.no {
				if tt.matcher.Matches(x) {
					t.Errorf(`"%v %s": got true, want false.`, x, tt.matcher)
				}
			}
		})
	}
}

// A more thorough test of notMatcher
func TestNotMatcher(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()

	mockMatcher := mock_gomock.NewMockMatcher(ctrl)
	notMatcher := gomock.Not(mockMatcher)

	mockMatcher.EXPECT().Matches(4).Return(true)
	if match := notMatcher.Matches(4); match {
		t.Errorf("notMatcher should not match 4")
	}

	mockMatcher.EXPECT().Matches(5).Return(false)
	if match := notMatcher.Matches(5); !match {
		t.Errorf("notMatcher should match 5")
	}
}

type Dog struct {
	Breed, Name string
}

type ctxKey struct{}

// A thorough test of assignableToTypeOfMatcher
func TestAssignableToTypeOfMatcher(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()

	aStr := "def"
	anotherStr := "ghi"

	if match := gomock.AssignableToTypeOf("abc").Matches(4); match {
		t.Errorf(`AssignableToTypeOf("abc") should not match 4`)
	}
	if match := gomock.AssignableToTypeOf("abc").Matches(&aStr); match {
		t.Errorf(`AssignableToTypeOf("abc") should not match &aStr (*string)`)
	}
	if match := gomock.AssignableToTypeOf("abc").Matches("def"); !match {
		t.Errorf(`AssignableToTypeOf("abc") should match "def"`)
	}
	if match := gomock.AssignableToTypeOf(&aStr).Matches("abc"); match {
		t.Errorf(`AssignableToTypeOf(&aStr) should not match "abc"`)
	}
	if match := gomock.AssignableToTypeOf(&aStr).Matches(&anotherStr); !match {
		t.Errorf(`AssignableToTypeOf(&aStr) should match &anotherStr`)
	}
	if match := gomock.AssignableToTypeOf(0).Matches(4); !match {
		t.Errorf(`AssignableToTypeOf(0) should match 4`)
	}
	if match := gomock.AssignableToTypeOf(0).Matches("def"); match {
		t.Errorf(`AssignableToTypeOf(0) should not match "def"`)
	}
	if match := gomock.AssignableToTypeOf(Dog{}).Matches(&Dog{}); match {
		t.Errorf(`AssignableToTypeOf(Dog{}) should not match &Dog{}`)
	}
	if match := gomock.AssignableToTypeOf(Dog{}).Matches(Dog{Breed: "pug", Name: "Fido"}); !match {
		t.Errorf(`AssignableToTypeOf(Dog{}) should match Dog{Breed: "pug", Name: "Fido"}`)
	}
	if match := gomock.AssignableToTypeOf(&Dog{}).Matches(Dog{}); match {
		t.Errorf(`AssignableToTypeOf(&Dog{}) should not match Dog{}`)
	}
	if match := gomock.AssignableToTypeOf(&Dog{}).Matches(&Dog{Breed: "pug", Name: "Fido"}); !match {
		t.Errorf(`AssignableToTypeOf(&Dog{}) should match &Dog{Breed: "pug", Name: "Fido"}`)
	}

	ctxInterface := reflect.TypeOf((*context.Context)(nil)).Elem()
	if match := gomock.AssignableToTypeOf(ctxInterface).Matches(context.Background()); !match {
		t.Errorf(`AssignableToTypeOf(context.Context) should not match context.Background()`)
	}

	ctxWithValue := context.WithValue(context.Background(), ctxKey{}, "val")
	if match := gomock.AssignableToTypeOf(ctxInterface).Matches(ctxWithValue); !match {
		t.Errorf(`AssignableToTypeOf(context.Context) should not match ctxWithValue`)
	}
}

func TestInAnyOrder(t *testing.T) {
	tests := []struct {
		name      string
		wanted    interface{}
		given     interface{}
		wantMatch bool
	}{
		{
			name:      "match for equal slices",
			wanted:    []int{1, 2, 3},
			given:     []int{1, 2, 3},
			wantMatch: true,
		},
		{
			name:      "match for slices with same elements of different order",
			wanted:    []int{1, 2, 3},
			given:     []int{1, 3, 2},
			wantMatch: true,
		},
		{
			name:      "not match for slices with different elements",
			wanted:    []int{1, 2, 3},
			given:     []int{1, 2, 4},
			wantMatch: false,
		},
		{
			name:      "not match for slices with missing elements",
			wanted:    []int{1, 2, 3},
			given:     []int{1, 2},
			wantMatch: false,
		},
		{
			name:      "not match for slices with extra elements",
			wanted:    []int{1, 2, 3},
			given:     []int{1, 2, 3, 4},
			wantMatch: false,
		},
		{
			name:      "match for empty slices",
			wanted:    []int{},
			given:     []int{},
			wantMatch: true,
		},
		{
			name:      "not match for equal slices of different types",
			wanted:    []float64{1, 2, 3},
			given:     []int{1, 2, 3},
			wantMatch: false,
		},
		{
			name:      "match for equal arrays",
			wanted:    [3]int{1, 2, 3},
			given:     [3]int{1, 2, 3},
			wantMatch: true,
		},
		{
			name:      "match for equal arrays of different order",
			wanted:    [3]int{1, 2, 3},
			given:     [3]int{1, 3, 2},
			wantMatch: true,
		},
		{
			name:      "not match for arrays of different elements",
			wanted:    [3]int{1, 2, 3},
			given:     [3]int{1, 2, 4},
			wantMatch: false,
		},
		{
			name:      "not match for arrays with extra elements",
			wanted:    [3]int{1, 2, 3},
			given:     [4]int{1, 2, 3, 4},
			wantMatch: false,
		},
		{
			name:      "not match for arrays with missing elements",
			wanted:    [3]int{1, 2, 3},
			given:     [2]int{1, 2},
			wantMatch: false,
		},
		{
			name:      "not match for equal strings", // matcher shouldn't treat strings as collections
			wanted:    "123",
			given:     "123",
			wantMatch: false,
		},
		{
			name:      "not match if x type is not iterable",
			wanted:    123,
			given:     []int{123},
			wantMatch: false,
		},
		{
			name:      "not match if in type is not iterable",
			wanted:    []int{123},
			given:     123,
			wantMatch: false,
		},
		{
			name:      "not match if both are not iterable",
			wanted:    123,
			given:     123,
			wantMatch: false,
		},
		{
			name:      "match for equal slices with unhashable elements",
			wanted:    [][]int{{1}, {1, 2}, {1, 2, 3}},
			given:     [][]int{{1}, {1, 2}, {1, 2, 3}},
			wantMatch: true,
		},
		{
			name:      "match for equal slices with unhashable elements of different order",
			wanted:    [][]int{{1}, {1, 2, 3}, {1, 2}},
			given:     [][]int{{1}, {1, 2}, {1, 2, 3}},
			wantMatch: true,
		},
		{
			name:      "not match for different slices with unhashable elements",
			wanted:    [][]int{{1}, {1, 2, 3}, {1, 2}},
			given:     [][]int{{1}, {1, 2, 4}, {1, 3}},
			wantMatch: false,
		},
		{
			name:      "not match for unhashable missing elements",
			wanted:    [][]int{{1}, {1, 2}, {1, 2, 3}},
			given:     [][]int{{1}, {1, 2}},
			wantMatch: false,
		},
		{
			name:      "not match for unhashable extra elements",
			wanted:    [][]int{{1}, {1, 2}},
			given:     [][]int{{1}, {1, 2}, {1, 2, 3}},
			wantMatch: false,
		},
		{
			name:      "match for equal slices of assignable types",
			wanted:    [][]string{{"a", "b"}},
			given:     []A{{"a", "b"}},
			wantMatch: true,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := gomock.InAnyOrder(tt.wanted).Matches(tt.given); got != tt.wantMatch {
				t.Errorf("got = %v, wantMatch %v", got, tt.wantMatch)
			}
		})
	}
}


================================================
FILE: gomock/mock_test.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: example_test.go

// Package gomock_test is a generated GoMock package.
package gomock_test

import (
	reflect "reflect"

	"github.com/golang/mock/gomock"
)

// MockFoo is a mock of Foo interface.
type MockFoo struct {
	ctrl     *gomock.Controller
	recorder *MockFooMockRecorder
}

// MockFooMockRecorder is the mock recorder for MockFoo.
type MockFooMockRecorder struct {
	mock *MockFoo
}

// NewMockFoo creates a new mock instance.
func NewMockFoo(ctrl *gomock.Controller) *MockFoo {
	mock := &MockFoo{ctrl: ctrl}
	mock.recorder = &MockFooMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockFoo) EXPECT() *MockFooMockRecorder {
	return m.recorder
}

// Bar mocks base method.
func (m *MockFoo) Bar(arg0 string) string {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Bar", arg0)
	ret0, _ := ret[0].(string)
	return ret0
}

// Bar indicates an expected call of Bar.
func (mr *MockFooMockRecorder) Bar(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Bar", reflect.TypeOf((*MockFoo)(nil).Bar), arg0)
}


================================================
FILE: mockgen/generic_go118.go
================================================
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build go1.18
// +build go1.18

package main

import (
	"go/ast"
	"strings"

	"github.com/golang/mock/mockgen/model"
)

func getTypeSpecTypeParams(ts *ast.TypeSpec) []*ast.Field {
	if ts == nil || ts.TypeParams == nil {
		return nil
	}
	return ts.TypeParams.List
}

func (p *fileParser) parseGenericType(pkg string, typ ast.Expr, tps map[string]bool) (model.Type, error) {
	switch v := typ.(type) {
	case *ast.IndexExpr:
		m, err := p.parseType(pkg, v.X, tps)
		if err != nil {
			return nil, err
		}
		nm, ok := m.(*model.NamedType)
		if !ok {
			return m, nil
		}
		t, err := p.parseType(pkg, v.Index, tps)
		if err != nil {
			return nil, err
		}
		nm.TypeParams = &model.TypeParametersType{TypeParameters: []model.Type{t}}
		return m, nil
	case *ast.IndexListExpr:
		m, err := p.parseType(pkg, v.X, tps)
		if err != nil {
			return nil, err
		}
		nm, ok := m.(*model.NamedType)
		if !ok {
			return m, nil
		}
		var ts []model.Type
		for _, expr := range v.Indices {
			t, err := p.parseType(pkg, expr, tps)
			if err != nil {
				return nil, err
			}
			ts = append(ts, t)
		}
		nm.TypeParams = &model.TypeParametersType{TypeParameters: ts}
		return m, nil
	}
	return nil, nil
}

func getIdentTypeParams(decl interface{}) string {
	if decl == nil {
		return ""
	}
	ts, ok := decl.(*ast.TypeSpec)
	if !ok {
		return ""
	}
	if ts.TypeParams == nil || len(ts.TypeParams.List) == 0 {
		return ""
	}
	var sb strings.Builder
	sb.WriteString("[")
	for i, v := range ts.TypeParams.List {
		if i != 0 {
			sb.WriteString(", ")
		}
		sb.WriteString(v.Names[0].Name)
	}
	sb.WriteString("]")
	return sb.String()
}


================================================
FILE: mockgen/generic_notgo118.go
================================================
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !go1.18
// +build !go1.18

package main

import (
	"go/ast"

	"github.com/golang/mock/mockgen/model"
)

func getTypeSpecTypeParams(ts *ast.TypeSpec) []*ast.Field {
	return nil
}

func (p *fileParser) parseGenericType(pkg string, typ ast.Expr, tps map[string]bool) (model.Type, error) {
	return nil, nil
}

func getIdentTypeParams(decl interface{}) string {
	return ""
}


================================================
FILE: mockgen/internal/tests/aux_imports_embedded_interface/README.md
================================================
# Embedded Interfaces in aux_files

Embedded interfaces in `aux_files` generate `unknown embedded interface XXX` errors.
See below for example of the problem:

```go
// source
import (
    alias "some.org/package/imported"
)

type Source interface {
    alias.Foreign
}
```

```go
// some.org/package/imported
type Foreign interface {
    Embedded
}

type Embedded interface {}
```

Attempting to generate a mock will result in an `unknown embedded interface Embedded`.
The issue is that the `fileParser` stores `auxInterfaces` underneath the package name
explicitly specified in the `aux_files` flag.

In the `parseInterface` method, there is an incorrect assumption about an embedded interface
always being in the source file.

```go
case *ast.Ident:
        // Embedded interface in this package.
        ei := p.auxInterfaces[""][v.String()]
        if ei == nil {
                return nil, p.errorf(v.Pos(), "unknown embedded interface %s", v.String())
        }
```


================================================
FILE: mockgen/internal/tests/aux_imports_embedded_interface/bugreport.go
================================================
package bugreport

//go:generate mockgen -aux_files faux=faux/faux.go -destination bugreport_mock.go -package bugreport -source=bugreport.go Example

import (
	"log"

	"github.com/golang/mock/mockgen/internal/tests/aux_imports_embedded_interface/faux"
)

// Source is an interface w/ an embedded foreign interface
type Source interface {
	faux.Foreign
}

func CallForeignMethod(s Source) {
	log.Println(s.Method())
}


================================================
FILE: mockgen/internal/tests/aux_imports_embedded_interface/bugreport_mock.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: bugreport.go

// Package bugreport is a generated GoMock package.
package bugreport

import (
	reflect "reflect"

	gomock "github.com/golang/mock/gomock"
	faux "github.com/golang/mock/mockgen/internal/tests/aux_imports_embedded_interface/faux"
)

// MockSource is a mock of Source interface.
type MockSource struct {
	ctrl     *gomock.Controller
	recorder *MockSourceMockRecorder
}

// MockSourceMockRecorder is the mock recorder for MockSource.
type MockSourceMockRecorder struct {
	mock *MockSource
}

// NewMockSource creates a new mock instance.
func NewMockSource(ctrl *gomock.Controller) *MockSource {
	mock := &MockSource{ctrl: ctrl}
	mock.recorder = &MockSourceMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockSource) EXPECT() *MockSourceMockRecorder {
	return m.recorder
}

// Error mocks base method.
func (m *MockSource) Error() string {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Error")
	ret0, _ := ret[0].(string)
	return ret0
}

// Error indicates an expected call of Error.
func (mr *MockSourceMockRecorder) Error() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Error", reflect.TypeOf((*MockSource)(nil).Error))
}

// Method mocks base method.
func (m *MockSource) Method() faux.Return {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Method")
	ret0, _ := ret[0].(faux.Return)
	return ret0
}

// Method indicates an expected call of Method.
func (mr *MockSourceMockRecorder) Method() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Method", reflect.TypeOf((*MockSource)(nil).Method))
}


================================================
FILE: mockgen/internal/tests/aux_imports_embedded_interface/bugreport_test.go
================================================
package bugreport

import (
	"testing"

	"github.com/golang/mock/gomock"
)

// TestValidInterface assesses whether or not the generated mock is valid
func TestValidInterface(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()

	s := NewMockSource(ctrl)
	s.EXPECT().Method().Return("")

	CallForeignMethod(s)
}


================================================
FILE: mockgen/internal/tests/aux_imports_embedded_interface/faux/faux.go
================================================
package faux

type Foreign interface {
	Method() Return
	Embedded
	error
}

type Embedded interface{}

type Return interface{}


================================================
FILE: mockgen/internal/tests/const_array_length/input.go
================================================
package const_length

import "math"

//go:generate mockgen -package const_length -destination mock.go -source input.go

const C = 2

type I interface {
	Foo() [C]int
	Bar() [2]int
	Baz() [math.MaxInt8]int
	Qux() [1 + 2]int
	Quux() [(1 + 2)]int
	Corge() [math.MaxInt8 - 120]int
}


================================================
FILE: mockgen/internal/tests/const_array_length/mock.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: input.go

// Package const_length is a generated GoMock package.
package const_length

import (
	reflect "reflect"

	gomock "github.com/golang/mock/gomock"
)

// MockI is a mock of I interface.
type MockI struct {
	ctrl     *gomock.Controller
	recorder *MockIMockRecorder
}

// MockIMockRecorder is the mock recorder for MockI.
type MockIMockRecorder struct {
	mock *MockI
}

// NewMockI creates a new mock instance.
func NewMockI(ctrl *gomock.Controller) *MockI {
	mock := &MockI{ctrl: ctrl}
	mock.recorder = &MockIMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockI) EXPECT() *MockIMockRecorder {
	return m.recorder
}

// Bar mocks base method.
func (m *MockI) Bar() [2]int {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Bar")
	ret0, _ := ret[0].([2]int)
	return ret0
}

// Bar indicates an expected call of Bar.
func (mr *MockIMockRecorder) Bar() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Bar", reflect.TypeOf((*MockI)(nil).Bar))
}

// Baz mocks base method.
func (m *MockI) Baz() [127]int {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Baz")
	ret0, _ := ret[0].([127]int)
	return ret0
}

// Baz indicates an expected call of Baz.
func (mr *MockIMockRecorder) Baz() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Baz", reflect.TypeOf((*MockI)(nil).Baz))
}

// Corge mocks base method.
func (m *MockI) Corge() [7]int {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Corge")
	ret0, _ := ret[0].([7]int)
	return ret0
}

// Corge indicates an expected call of Corge.
func (mr *MockIMockRecorder) Corge() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Corge", reflect.TypeOf((*MockI)(nil).Corge))
}

// Foo mocks base method.
func (m *MockI) Foo() [2]int {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Foo")
	ret0, _ := ret[0].([2]int)
	return ret0
}

// Foo indicates an expected call of Foo.
func (mr *MockIMockRecorder) Foo() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Foo", reflect.TypeOf((*MockI)(nil).Foo))
}

// Quux mocks base method.
func (m *MockI) Quux() [3]int {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Quux")
	ret0, _ := ret[0].([3]int)
	return ret0
}

// Quux indicates an expected call of Quux.
func (mr *MockIMockRecorder) Quux() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Quux", reflect.TypeOf((*MockI)(nil).Quux))
}

// Qux mocks base method.
func (m *MockI) Qux() [3]int {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Qux")
	ret0, _ := ret[0].([3]int)
	return ret0
}

// Qux indicates an expected call of Qux.
func (mr *MockIMockRecorder) Qux() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Qux", reflect.TypeOf((*MockI)(nil).Qux))
}


================================================
FILE: mockgen/internal/tests/copyright_file/input.go
================================================
package empty_interface

//go:generate mockgen -package empty_interface -destination mock.go -source input.go -copyright_file=mock_copyright_header

type Empty interface{}


================================================
FILE: mockgen/internal/tests/copyright_file/mock.go
================================================
// This is a mock copyright header.
//
// Lorem ipsum dolor sit amet, consectetur adipiscing elit,
// sed do eiusmod tempor incididunt ut labore et dolore magna
// aliqua. Velit ut tortor pretium viverra suspendisse potenti.
//

// Code generated by MockGen. DO NOT EDIT.
// Source: input.go

// Package empty_interface is a generated GoMock package.
package empty_interface

import (
	gomock "github.com/golang/mock/gomock"
)

// MockEmpty is a mock of Empty interface.
type MockEmpty struct {
	ctrl     *gomock.Controller
	recorder *MockEmptyMockRecorder
}

// MockEmptyMockRecorder is the mock recorder for MockEmpty.
type MockEmptyMockRecorder struct {
	mock *MockEmpty
}

// NewMockEmpty creates a new mock instance.
func NewMockEmpty(ctrl *gomock.Controller) *MockEmpty {
	mock := &MockEmpty{ctrl: ctrl}
	mock.recorder = &MockEmptyMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockEmpty) EXPECT() *MockEmptyMockRecorder {
	return m.recorder
}


================================================
FILE: mockgen/internal/tests/copyright_file/mock_copyright_header
================================================
This is a mock copyright header.

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna 
aliqua. Velit ut tortor pretium viverra suspendisse potenti.


================================================
FILE: mockgen/internal/tests/custom_package_name/README.md
================================================
# Tests for custom package names

This directory contains test for mockgen generating mocks when imported package
name does not match import path suffix. For example, package with name "client"
is located under import path "github.com/golang/mock/mockgen/internal/tests/custom_package_name/client/v1".

Prior to this patch:

```bash
$ go generate greeter/greeter.go
2018/03/05 22:44:52 Loading input failed: greeter.go:17:11: failed parsing returns: greeter.go:17:14: unknown package "client"
greeter/greeter.go:1: running "mockgen": exit status 1
```

This can be fixed by manually providing `-imports` flag, like `-imports client=github.com/golang/mock/mockgen/internal/tests/custom_package_name/client/v1`.
But, mockgen should be able to automatically resolve package names in such situations.

With this patch applied:

```bash
$ go generate greeter/greeter.go
$ echo $?
0
```

Mockgen runs successfully, produced output is equal to [greeter_mock_test.go](greeter/greeter_mock_test.go) content.


================================================
FILE: mockgen/internal/tests/custom_package_name/client/v1/client.go
================================================
package client

import "fmt"

type Client struct{}

func (c *Client) Greet(in GreetInput) string {
	return fmt.Sprintf("Hello, %s!", in.Name)
}

type GreetInput struct {
	Name string
}


================================================
FILE: mockgen/internal/tests/custom_package_name/greeter/greeter.go
================================================
package greeter

//go:generate mockgen -source greeter.go -destination greeter_mock_test.go -package greeter

import (
	// stdlib import
	"fmt"

	// non-matching import suffix and package name
	"github.com/golang/mock/mockgen/internal/tests/custom_package_name/client/v1"

	//  matching import suffix and package name
	"github.com/golang/mock/mockgen/internal/tests/custom_package_name/validator"
)

type InputMaker interface {
	MakeInput() client.GreetInput
}

type Greeter struct {
	InputMaker InputMaker
	Client     *client.Client
}

func (g *Greeter) Greet() (string, error) {
	in := g.InputMaker.MakeInput()
	if err := validator.Validate(in.Name); err != nil {
		return "", fmt.Errorf("validation failed: %v", err)
	}
	return g.Client.Greet(in), nil
}


================================================
FILE: mockgen/internal/tests/custom_package_name/greeter/greeter_mock_test.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: greeter.go

// Package greeter is a generated GoMock package.
package greeter

import (
	reflect "reflect"

	gomock "github.com/golang/mock/gomock"
	client "github.com/golang/mock/mockgen/internal/tests/custom_package_name/client/v1"
)

// MockInputMaker is a mock of InputMaker interface.
type MockInputMaker struct {
	ctrl     *gomock.Controller
	recorder *MockInputMakerMockRecorder
}

// MockInputMakerMockRecorder is the mock recorder for MockInputMaker.
type MockInputMakerMockRecorder struct {
	mock *MockInputMaker
}

// NewMockInputMaker creates a new mock instance.
func NewMockInputMaker(ctrl *gomock.Controller) *MockInputMaker {
	mock := &MockInputMaker{ctrl: ctrl}
	mock.recorder = &MockInputMakerMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockInputMaker) EXPECT() *MockInputMakerMockRecorder {
	return m.recorder
}

// MakeInput mocks base method.
func (m *MockInputMaker) MakeInput() client.GreetInput {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "MakeInput")
	ret0, _ := ret[0].(client.GreetInput)
	return ret0
}

// MakeInput indicates an expected call of MakeInput.
func (mr *MockInputMakerMockRecorder) MakeInput() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MakeInput", reflect.TypeOf((*MockInputMaker)(nil).MakeInput))
}


================================================
FILE: mockgen/internal/tests/custom_package_name/greeter/greeter_test.go
================================================
package greeter

import (
	"testing"

	"github.com/golang/mock/gomock"
	"github.com/golang/mock/mockgen/internal/tests/custom_package_name/client/v1"
)

func TestGreeter_Greet(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()

	input := client.GreetInput{
		Name: "Foo",
	}

	inputMaker := NewMockInputMaker(ctrl)
	inputMaker.EXPECT().
		MakeInput().
		Return(input)

	g := &Greeter{
		InputMaker: inputMaker,
		Client:     &client.Client{},
	}

	greeting, err := g.Greet()
	if err != nil {
		t.Fatalf("Unexpected error: %v", err)
	}

	expected := "Hello, Foo!"
	if greeting != expected {
		t.Fatalf("Expected greeting to be %v but got %v", expected, greeting)
	}
}


================================================
FILE: mockgen/internal/tests/custom_package_name/validator/validate.go
================================================
package validator

func Validate(s string) error {
	return nil
}


================================================
FILE: mockgen/internal/tests/dot_imports/input.go
================================================
package dot_imports

//go:generate mockgen -package dot_imports -destination mock.go -source input.go

import (
	"bytes"
	. "context"
	. "net/http"
)

type WithDotImports interface {
	Method1() Request
	Method2() *bytes.Buffer
	Method3() Context
}


================================================
FILE: mockgen/internal/tests/dot_imports/mock.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: input.go

// Package dot_imports is a generated GoMock package.
package dot_imports

import (
	bytes "bytes"
	. "context"
	. "net/http"
	reflect "reflect"

	gomock "github.com/golang/mock/gomock"
)

// MockWithDotImports is a mock of WithDotImports interface.
type MockWithDotImports struct {
	ctrl     *gomock.Controller
	recorder *MockWithDotImportsMockRecorder
}

// MockWithDotImportsMockRecorder is the mock recorder for MockWithDotImports.
type MockWithDotImportsMockRecorder struct {
	mock *MockWithDotImports
}

// NewMockWithDotImports creates a new mock instance.
func NewMockWithDotImports(ctrl *gomock.Controller) *MockWithDotImports {
	mock := &MockWithDotImports{ctrl: ctrl}
	mock.recorder = &MockWithDotImportsMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockWithDotImports) EXPECT() *MockWithDotImportsMockRecorder {
	return m.recorder
}

// Method1 mocks base method.
func (m *MockWithDotImports) Method1() Request {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Method1")
	ret0, _ := ret[0].(Request)
	return ret0
}

// Method1 indicates an expected call of Method1.
func (mr *MockWithDotImportsMockRecorder) Method1() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Method1", reflect.TypeOf((*MockWithDotImports)(nil).Method1))
}

// Method2 mocks base method.
func (m *MockWithDotImports) Method2() *bytes.Buffer {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Method2")
	ret0, _ := ret[0].(*bytes.Buffer)
	return ret0
}

// Method2 indicates an expected call of Method2.
func (mr *MockWithDotImportsMockRecorder) Method2() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Method2", reflect.TypeOf((*MockWithDotImports)(nil).Method2))
}

// Method3 mocks base method.
func (m *MockWithDotImports) Method3() Context {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Method3")
	ret0, _ := ret[0].(Context)
	return ret0
}

// Method3 indicates an expected call of Method3.
func (mr *MockWithDotImportsMockRecorder) Method3() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Method3", reflect.TypeOf((*MockWithDotImports)(nil).Method3))
}


================================================
FILE: mockgen/internal/tests/empty_interface/input.go
================================================
package empty_interface

//go:generate mockgen -package empty_interface -destination mock.go -source input.go

type Empty interface{}


================================================
FILE: mockgen/internal/tests/empty_interface/mock.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: input.go

// Package empty_interface is a generated GoMock package.
package empty_interface

import (
	gomock "github.com/golang/mock/gomock"
)

// MockEmpty is a mock of Empty interface.
type MockEmpty struct {
	ctrl     *gomock.Controller
	recorder *MockEmptyMockRecorder
}

// MockEmptyMockRecorder is the mock recorder for MockEmpty.
type MockEmptyMockRecorder struct {
	mock *MockEmpty
}

// NewMockEmpty creates a new mock instance.
func NewMockEmpty(ctrl *gomock.Controller) *MockEmpty {
	mock := &MockEmpty{ctrl: ctrl}
	mock.recorder = &MockEmptyMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockEmpty) EXPECT() *MockEmptyMockRecorder {
	return m.recorder
}


================================================
FILE: mockgen/internal/tests/extra_import/import.go
================================================
// Package extra_import makes sure output does not import it. See #515.
package extra_import

//go:generate mockgen -destination mock.go -package extra_import . Foo

type Message struct {
	Text string
}

type Foo interface {
	Bar(channels []string, message chan<- Message)
}


================================================
FILE: mockgen/internal/tests/extra_import/mock.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/golang/mock/mockgen/internal/tests/extra_import (interfaces: Foo)

// Package extra_import is a generated GoMock package.
package extra_import

import (
	reflect "reflect"

	gomock "github.com/golang/mock/gomock"
)

// MockFoo is a mock of Foo interface.
type MockFoo struct {
	ctrl     *gomock.Controller
	recorder *MockFooMockRecorder
}

// MockFooMockRecorder is the mock recorder for MockFoo.
type MockFooMockRecorder struct {
	mock *MockFoo
}

// NewMockFoo creates a new mock instance.
func NewMockFoo(ctrl *gomock.Controller) *MockFoo {
	mock := &MockFoo{ctrl: ctrl}
	mock.recorder = &MockFooMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockFoo) EXPECT() *MockFooMockRecorder {
	return m.recorder
}

// Bar mocks base method.
func (m *MockFoo) Bar(arg0 []string, arg1 chan<- Message) {
	m.ctrl.T.Helper()
	m.ctrl.Call(m, "Bar", arg0, arg1)
}

// Bar indicates an expected call of Bar.
func (mr *MockFooMockRecorder) Bar(arg0, arg1 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Bar", reflect.TypeOf((*MockFoo)(nil).Bar), arg0, arg1)
}


================================================
FILE: mockgen/internal/tests/generated_identifier_conflict/README.md
================================================
# Generated Identifier Conflict

The generated mock methods use some hardcoded variable/receiver names that can
have conflicts with the argument names that are defined by the code for which
the mock is generated when using the source generation method.

Example:

```go
type Example interface {
    Method(_m, _mr, m, mr int)
}
```

```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)
}
```

In the above example one of the interface method parameters is called `_m`
but unfortunately the generated receiver name is also called `_m` so the
mock code won't compile.

The generator has to make sure that generated identifiers (e.g.: the receiver
names) are always different from the arg names that might come from external
sources.


================================================
FILE: mockgen/internal/tests/generated_identifier_conflict/bugreport.go
================================================
package bugreport

//go:generate mockgen -destination bugreport_mock.go -package bugreport -source=bugreport.go

type Example interface {
	// _m and _mr were used by the buggy code: the '_' prefix was there hoping
	// that no one will use method argument names starting with '_' reducing
	// the chance of collision with generated identifiers.
	// m and mr are used by the bugfixed new code, the '_' prefix has been
	// removed because the new code generator changes the names of the
	// generated identifiers in case they would collide with identifiers
	// coming from argument names.
	Method(_m, _mr, m, mr int)

	VarargMethod(_s, _x, a, ret int, varargs ...int)
}


================================================
FILE: mockgen/internal/tests/generated_identifier_conflict/bugreport_mock.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: bugreport.go

// Package bugreport is a generated GoMock package.
package bugreport

import (
	reflect "reflect"

	gomock "github.com/golang/mock/gomock"
)

// MockExample is a mock of Example interface.
type MockExample struct {
	ctrl     *gomock.Controller
	recorder *MockExampleMockRecorder
}

// MockExampleMockRecorder is the mock recorder for MockExample.
type MockExampleMockRecorder struct {
	mock *MockExample
}

// NewMockExample creates a new mock instance.
func NewMockExample(ctrl *gomock.Controller) *MockExample {
	mock := &MockExample{ctrl: ctrl}
	mock.recorder = &MockExampleMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockExample) EXPECT() *MockExampleMockRecorder {
	return m.recorder
}

// Method mocks base method.
func (m_2 *MockExample) Method(_m, _mr, m, mr int) {
	m_2.ctrl.T.Helper()
	m_2.ctrl.Call(m_2, "Method", _m, _mr, m, mr)
}

// Method indicates an expected call of Method.
func (mr_2 *MockExampleMockRecorder) Method(_m, _mr, m, mr interface{}) *gomock.Call {
	mr_2.mock.ctrl.T.Helper()
	return mr_2.mock.ctrl.RecordCallWithMethodType(mr_2.mock, "Method", reflect.TypeOf((*MockExample)(nil).Method), _m, _mr, m, mr)
}

// VarargMethod mocks base method.
func (m *MockExample) VarargMethod(_s, _x, a, ret int, varargs ...int) {
	m.ctrl.T.Helper()
	varargs_2 := []interface{}{_s, _x, a, ret}
	for _, a_2 := range varargs {
		varargs_2 = append(varargs_2, a_2)
	}
	m.ctrl.Call(m, "VarargMethod", varargs_2...)
}

// VarargMethod indicates an expected call of VarargMethod.
func (mr *MockExampleMockRecorder) VarargMethod(_s, _x, a, ret interface{}, varargs ...interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	varargs_2 := append([]interface{}{_s, _x, a, ret}, varargs...)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VarargMethod", reflect.TypeOf((*MockExample)(nil).VarargMethod), varargs_2...)
}


================================================
FILE: mockgen/internal/tests/generated_identifier_conflict/bugreport_test.go
================================================
package bugreport

import (
	"github.com/golang/mock/gomock"
	"testing"
)

func TestExample_Method(t *testing.T) {
	ctrl := gomock.NewController(t)
	m := NewMockExample(ctrl)
	m.EXPECT().Method(1, 2, 3, 4)

	m.Method(1, 2, 3, 4)

	ctrl.Finish()
}

func TestExample_VarargMethod(t *testing.T) {
	ctrl := gomock.NewController(t)
	m := NewMockExample(ctrl)
	m.EXPECT().VarargMethod(1, 2, 3, 4, 6, 7)

	m.VarargMethod(1, 2, 3, 4, 6, 7)

	ctrl.Finish()
}


================================================
FILE: mockgen/internal/tests/generics/external.go
================================================
package generics

import (
	"github.com/golang/mock/mockgen/internal/tests/generics/other"
	"golang.org/x/exp/constraints"
)

//go:generate mockgen --source=external.go --destination=source/mock_external_test.go --package source

type ExternalConstraint[I constraints.Integer, F constraints.Float] interface {
	One(string) string
	Two(I) string
	Three(I) F
	Four(I) Foo[I, F]
	Five(I) Baz[F]
	Six(I) *Baz[F]
	Seven(I) other.One[I]
	Eight(F) other.Two[I, F]
	Nine(Iface[I])
	Ten(*I)
}


================================================
FILE: mockgen/internal/tests/generics/generics.go
================================================
package generics

import "github.com/golang/mock/mockgen/internal/tests/generics/other"

//go:generate mockgen --source=generics.go --destination=source/mock_generics_test.go --package source
////go:generate mockgen --destination=reflect/mock_test.go --package reflect . Bar,Bar2

type Bar[T any, R any] interface {
	One(string) string
	Two(T) string
	Three(T) R
	Four(T) Foo[T, R]
	Five(T) Baz[T]
	Six(T) *Baz[T]
	Seven(T) other.One[T]
	Eight(T) other.Two[T, R]
	Nine(Iface[T])
	Ten(*T)
	Eleven() (*other.One[T], error)
	Twelve() (*other.Two[T, R], error)
	Thirteen() (Baz[StructType], error)
	Fourteen() (*Foo[StructType, StructType2], error)
	Fifteen() (Iface[StructType], error)
	Sixteen() (Baz[other.Three], error)
	Seventeen() (*Foo[other.Three, other.Four], error)
	Eighteen() (Iface[*other.Five], error)
	Nineteen() AliasType
}

type Foo[T any, R any] struct{}

type Baz[T any] struct{}

type Iface[T any] interface{}

type StructType struct{}

type StructType2 struct{}

type AliasType Baz[other.Three]


================================================
FILE: mockgen/internal/tests/generics/go.mod
================================================
module github.com/golang/mock/mockgen/internal/tests/generics

go 1.18

require (
	github.com/golang/mock v1.6.0
	golang.org/x/exp v0.0.0-20220428152302-39d4317da171
)

replace github.com/golang/mock => ../../../..


================================================
FILE: mockgen/internal/tests/generics/go.sum
================================================
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20220428152302-39d4317da171 h1:TfdoLivD44QwvssI9Sv1xwa5DcL5XQr4au4sZ2F2NV4=
golang.org/x/exp v0.0.0-20220428152302-39d4317da171/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=


================================================
FILE: mockgen/internal/tests/generics/other/other.go
================================================
package other

type One[T any] struct{}

type Two[T any, R any] struct{}

type Three struct{}

type Four struct{}

type Five interface{}


================================================
FILE: mockgen/internal/tests/generics/source/mock_external_test.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: external.go

// Package source is a generated GoMock package.
package source

import (
	reflect "reflect"

	gomock "github.com/golang/mock/gomock"
	generics "github.com/golang/mock/mockgen/internal/tests/generics"
	other "github.com/golang/mock/mockgen/internal/tests/generics/other"
	constraints "golang.org/x/exp/constraints"
)

// MockExternalConstraint is a mock of ExternalConstraint interface.
type MockExternalConstraint[I constraints.Integer, F constraints.Float] struct {
	ctrl     *gomock.Controller
	recorder *MockExternalConstraintMockRecorder[I, F]
}

// MockExternalConstraintMockRecorder is the mock recorder for MockExternalConstraint.
type MockExternalConstraintMockRecorder[I constraints.Integer, F constraints.Float] struct {
	mock *MockExternalConstraint[I, F]
}

// NewMockExternalConstraint creates a new mock instance.
func NewMockExternalConstraint[I constraints.Integer, F constraints.Float](ctrl *gomock.Controller) *MockExternalConstraint[I, F] {
	mock := &MockExternalConstraint[I, F]{ctrl: ctrl}
	mock.recorder = &MockExternalConstraintMockRecorder[I, F]{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockExternalConstraint[I, F]) EXPECT() *MockExternalConstraintMockRecorder[I, F] {
	return m.recorder
}

// Eight mocks base method.
func (m *MockExternalConstraint[I, F]) Eight(arg0 F) other.Two[I, F] {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Eight", arg0)
	ret0, _ := ret[0].(other.Two[I, F])
	return ret0
}

// Eight indicates an expected call of Eight.
func (mr *MockExternalConstraintMockRecorder[I, F]) Eight(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eight", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Eight), arg0)
}

// Five mocks base method.
func (m *MockExternalConstraint[I, F]) Five(arg0 I) generics.Baz[F] {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Five", arg0)
	ret0, _ := ret[0].(generics.Baz[F])
	return ret0
}

// Five indicates an expected call of Five.
func (mr *MockExternalConstraintMockRecorder[I, F]) Five(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Five", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Five), arg0)
}

// Four mocks base method.
func (m *MockExternalConstraint[I, F]) Four(arg0 I) generics.Foo[I, F] {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Four", arg0)
	ret0, _ := ret[0].(generics.Foo[I, F])
	return ret0
}

// Four indicates an expected call of Four.
func (mr *MockExternalConstraintMockRecorder[I, F]) Four(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Four", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Four), arg0)
}

// Nine mocks base method.
func (m *MockExternalConstraint[I, F]) Nine(arg0 generics.Iface[I]) {
	m.ctrl.T.Helper()
	m.ctrl.Call(m, "Nine", arg0)
}

// Nine indicates an expected call of Nine.
func (mr *MockExternalConstraintMockRecorder[I, F]) Nine(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Nine", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Nine), arg0)
}

// One mocks base method.
func (m *MockExternalConstraint[I, F]) One(arg0 string) string {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "One", arg0)
	ret0, _ := ret[0].(string)
	return ret0
}

// One indicates an expected call of One.
func (mr *MockExternalConstraintMockRecorder[I, F]) One(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "One", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).One), arg0)
}

// Seven mocks base method.
func (m *MockExternalConstraint[I, F]) Seven(arg0 I) other.One[I] {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Seven", arg0)
	ret0, _ := ret[0].(other.One[I])
	return ret0
}

// Seven indicates an expected call of Seven.
func (mr *MockExternalConstraintMockRecorder[I, F]) Seven(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Seven", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Seven), arg0)
}

// Six mocks base method.
func (m *MockExternalConstraint[I, F]) Six(arg0 I) *generics.Baz[F] {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Six", arg0)
	ret0, _ := ret[0].(*generics.Baz[F])
	return ret0
}

// Six indicates an expected call of Six.
func (mr *MockExternalConstraintMockRecorder[I, F]) Six(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Six", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Six), arg0)
}

// Ten mocks base method.
func (m *MockExternalConstraint[I, F]) Ten(arg0 *I) {
	m.ctrl.T.Helper()
	m.ctrl.Call(m, "Ten", arg0)
}

// Ten indicates an expected call of Ten.
func (mr *MockExternalConstraintMockRecorder[I, F]) Ten(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ten", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Ten), arg0)
}

// Three mocks base method.
func (m *MockExternalConstraint[I, F]) Three(arg0 I) F {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Three", arg0)
	ret0, _ := ret[0].(F)
	return ret0
}

// Three indicates an expected call of Three.
func (mr *MockExternalConstraintMockRecorder[I, F]) Three(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Three", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Three), arg0)
}

// Two mocks base method.
func (m *MockExternalConstraint[I, F]) Two(arg0 I) string {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Two", arg0)
	ret0, _ := ret[0].(string)
	return ret0
}

// Two indicates an expected call of Two.
func (mr *MockExternalConstraintMockRecorder[I, F]) Two(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Two", reflect.TypeOf((*MockExternalConstraint[I, F])(nil).Two), arg0)
}


================================================
FILE: mockgen/internal/tests/generics/source/mock_generics_test.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: generics.go

// Package source is a generated GoMock package.
package source

import (
	reflect "reflect"

	gomock "github.com/golang/mock/gomock"
	generics "github.com/golang/mock/mockgen/internal/tests/generics"
	other "github.com/golang/mock/mockgen/internal/tests/generics/other"
)

// MockBar is a mock of Bar interface.
type MockBar[T any, R any] struct {
	ctrl     *gomock.Controller
	recorder *MockBarMockRecorder[T, R]
}

// MockBarMockRecorder is the mock recorder for MockBar.
type MockBarMockRecorder[T any, R any] struct {
	mock *MockBar[T, R]
}

// NewMockBar creates a new mock instance.
func NewMockBar[T any, R any](ctrl *gomock.Controller) *MockBar[T, R] {
	mock := &MockBar[T, R]{ctrl: ctrl}
	mock.recorder = &MockBarMockRecorder[T, R]{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockBar[T, R]) EXPECT() *MockBarMockRecorder[T, R] {
	return m.recorder
}

// Eight mocks base method.
func (m *MockBar[T, R]) Eight(arg0 T) other.Two[T, R] {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Eight", arg0)
	ret0, _ := ret[0].(other.Two[T, R])
	return ret0
}

// Eight indicates an expected call of Eight.
func (mr *MockBarMockRecorder[T, R]) Eight(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eight", reflect.TypeOf((*MockBar[T, R])(nil).Eight), arg0)
}

// Eighteen mocks base method.
func (m *MockBar[T, R]) Eighteen() (generics.Iface[*other.Five], error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Eighteen")
	ret0, _ := ret[0].(generics.Iface[*other.Five])
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// Eighteen indicates an expected call of Eighteen.
func (mr *MockBarMockRecorder[T, R]) Eighteen() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eighteen", reflect.TypeOf((*MockBar[T, R])(nil).Eighteen))
}

// Eleven mocks base method.
func (m *MockBar[T, R]) Eleven() (*other.One[T], error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Eleven")
	ret0, _ := ret[0].(*other.One[T])
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// Eleven indicates an expected call of Eleven.
func (mr *MockBarMockRecorder[T, R]) Eleven() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Eleven", reflect.TypeOf((*MockBar[T, R])(nil).Eleven))
}

// Fifteen mocks base method.
func (m *MockBar[T, R]) Fifteen() (generics.Iface[generics.StructType], error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Fifteen")
	ret0, _ := ret[0].(generics.Iface[generics.StructType])
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// Fifteen indicates an expected call of Fifteen.
func (mr *MockBarMockRecorder[T, R]) Fifteen() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Fifteen", reflect.TypeOf((*MockBar[T, R])(nil).Fifteen))
}

// Five mocks base method.
func (m *MockBar[T, R]) Five(arg0 T) generics.Baz[T] {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Five", arg0)
	ret0, _ := ret[0].(generics.Baz[T])
	return ret0
}

// Five indicates an expected call of Five.
func (mr *MockBarMockRecorder[T, R]) Five(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Five", reflect.TypeOf((*MockBar[T, R])(nil).Five), arg0)
}

// Four mocks base method.
func (m *MockBar[T, R]) Four(arg0 T) generics.Foo[T, R] {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Four", arg0)
	ret0, _ := ret[0].(generics.Foo[T, R])
	return ret0
}

// Four indicates an expected call of Four.
func (mr *MockBarMockRecorder[T, R]) Four(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Four", reflect.TypeOf((*MockBar[T, R])(nil).Four), arg0)
}

// Fourteen mocks base method.
func (m *MockBar[T, R]) Fourteen() (*generics.Foo[generics.StructType, generics.StructType2], error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Fourteen")
	ret0, _ := ret[0].(*generics.Foo[generics.StructType, generics.StructType2])
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// Fourteen indicates an expected call of Fourteen.
func (mr *MockBarMockRecorder[T, R]) Fourteen() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Fourteen", reflect.TypeOf((*MockBar[T, R])(nil).Fourteen))
}

// Nine mocks base method.
func (m *MockBar[T, R]) Nine(arg0 generics.Iface[T]) {
	m.ctrl.T.Helper()
	m.ctrl.Call(m, "Nine", arg0)
}

// Nine indicates an expected call of Nine.
func (mr *MockBarMockRecorder[T, R]) Nine(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Nine", reflect.TypeOf((*MockBar[T, R])(nil).Nine), arg0)
}

// Nineteen mocks base method.
func (m *MockBar[T, R]) Nineteen() generics.AliasType {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Nineteen")
	ret0, _ := ret[0].(generics.AliasType)
	return ret0
}

// Nineteen indicates an expected call of Nineteen.
func (mr *MockBarMockRecorder[T, R]) Nineteen() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Nineteen", reflect.TypeOf((*MockBar[T, R])(nil).Nineteen))
}

// One mocks base method.
func (m *MockBar[T, R]) One(arg0 string) string {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "One", arg0)
	ret0, _ := ret[0].(string)
	return ret0
}

// One indicates an expected call of One.
func (mr *MockBarMockRecorder[T, R]) One(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "One", reflect.TypeOf((*MockBar[T, R])(nil).One), arg0)
}

// Seven mocks base method.
func (m *MockBar[T, R]) Seven(arg0 T) other.One[T] {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Seven", arg0)
	ret0, _ := ret[0].(other.One[T])
	return ret0
}

// Seven indicates an expected call of Seven.
func (mr *MockBarMockRecorder[T, R]) Seven(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Seven", reflect.TypeOf((*MockBar[T, R])(nil).Seven), arg0)
}

// Seventeen mocks base method.
func (m *MockBar[T, R]) Seventeen() (*generics.Foo[other.Three, other.Four], error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Seventeen")
	ret0, _ := ret[0].(*generics.Foo[other.Three, other.Four])
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// Seventeen indicates an expected call of Seventeen.
func (mr *MockBarMockRecorder[T, R]) Seventeen() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Seventeen", reflect.TypeOf((*MockBar[T, R])(nil).Seventeen))
}

// Six mocks base method.
func (m *MockBar[T, R]) Six(arg0 T) *generics.Baz[T] {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Six", arg0)
	ret0, _ := ret[0].(*generics.Baz[T])
	return ret0
}

// Six indicates an expected call of Six.
func (mr *MockBarMockRecorder[T, R]) Six(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Six", reflect.TypeOf((*MockBar[T, R])(nil).Six), arg0)
}

// Sixteen mocks base method.
func (m *MockBar[T, R]) Sixteen() (generics.Baz[other.Three], error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Sixteen")
	ret0, _ := ret[0].(generics.Baz[other.Three])
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// Sixteen indicates an expected call of Sixteen.
func (mr *MockBarMockRecorder[T, R]) Sixteen() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sixteen", reflect.TypeOf((*MockBar[T, R])(nil).Sixteen))
}

// Ten mocks base method.
func (m *MockBar[T, R]) Ten(arg0 *T) {
	m.ctrl.T.Helper()
	m.ctrl.Call(m, "Ten", arg0)
}

// Ten indicates an expected call of Ten.
func (mr *MockBarMockRecorder[T, R]) Ten(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ten", reflect.TypeOf((*MockBar[T, R])(nil).Ten), arg0)
}

// Thirteen mocks base method.
func (m *MockBar[T, R]) Thirteen() (generics.Baz[generics.StructType], error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Thirteen")
	ret0, _ := ret[0].(generics.Baz[generics.StructType])
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// Thirteen indicates an expected call of Thirteen.
func (mr *MockBarMockRecorder[T, R]) Thirteen() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Thirteen", reflect.TypeOf((*MockBar[T, R])(nil).Thirteen))
}

// Three mocks base method.
func (m *MockBar[T, R]) Three(arg0 T) R {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Three", arg0)
	ret0, _ := ret[0].(R)
	return ret0
}

// Three indicates an expected call of Three.
func (mr *MockBarMockRecorder[T, R]) Three(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Three", reflect.TypeOf((*MockBar[T, R])(nil).Three), arg0)
}

// Twelve mocks base method.
func (m *MockBar[T, R]) Twelve() (*other.Two[T, R], error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Twelve")
	ret0, _ := ret[0].(*other.Two[T, R])
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// Twelve indicates an expected call of Twelve.
func (mr *MockBarMockRecorder[T, R]) Twelve() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Twelve", reflect.TypeOf((*MockBar[T, R])(nil).Twelve))
}

// Two mocks base method.
func (m *MockBar[T, R]) Two(arg0 T) string {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Two", arg0)
	ret0, _ := ret[0].(string)
	return ret0
}

// Two indicates an expected call of Two.
func (mr *MockBarMockRecorder[T, R]) Two(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Two", reflect.TypeOf((*MockBar[T, R])(nil).Two), arg0)
}

// MockIface is a mock of Iface interface.
type MockIface[T any] struct {
	ctrl     *gomock.Controller
	recorder *MockIfaceMockRecorder[T]
}

// MockIfaceMockRecorder is the mock recorder for MockIface.
type MockIfaceMockRecorder[T any] struct {
	mock *MockIface[T]
}

// NewMockIface creates a new mock instance.
func NewMockIface[T any](ctrl *gomock.Controller) *MockIface[T] {
	mock := &MockIface[T]{ctrl: ctrl}
	mock.recorder = &MockIfaceMockRecorder[T]{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIface[T]) EXPECT() *MockIfaceMockRecorder[T] {
	return m.recorder
}


================================================
FILE: mockgen/internal/tests/import_embedded_interface/bugreport.go
================================================
// Copyright 2020 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package bugreport

//go:generate mockgen -destination bugreport_mock.go -package bugreport -source=bugreport.go

import (
	"log"

	"github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/ersatz"
	"github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/faux"
)

// Source is an interface w/ an embedded foreign interface
type Source interface {
	ersatz.Embedded
	faux.Foreign
	error
	Foo
}

func CallForeignMethod(s Source) {
	log.Println(s.Ersatz())
	log.Println(s.OtherErsatz())
}


================================================
FILE: mockgen/internal/tests/import_embedded_interface/bugreport_mock.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: bugreport.go

// Package bugreport is a generated GoMock package.
package bugreport

import (
	reflect "reflect"

	gomock "github.com/golang/mock/gomock"
	ersatz "github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/ersatz"
	ersatz0 "github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/other/ersatz"
)

// MockSource is a mock of Source interface.
type MockSource struct {
	ctrl     *gomock.Controller
	recorder *MockSourceMockRecorder
}

// MockSourceMockRecorder is the mock recorder for MockSource.
type MockSourceMockRecorder struct {
	mock *MockSource
}

// NewMockSource creates a new mock instance.
func NewMockSource(ctrl *gomock.Controller) *MockSource {
	mock := &MockSource{ctrl: ctrl}
	mock.recorder = &MockSourceMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockSource) EXPECT() *MockSourceMockRecorder {
	return m.recorder
}

// Bar mocks base method.
func (m *MockSource) Bar() Baz {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Bar")
	ret0, _ := ret[0].(Baz)
	return ret0
}

// Bar indicates an expected call of Bar.
func (mr *MockSourceMockRecorder) Bar() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Bar", reflect.TypeOf((*MockSource)(nil).Bar))
}

// Error mocks base method.
func (m *MockSource) Error() string {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Error")
	ret0, _ := ret[0].(string)
	return ret0
}

// Error indicates an expected call of Error.
func (mr *MockSourceMockRecorder) Error() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Error", reflect.TypeOf((*MockSource)(nil).Error))
}

// Ersatz mocks base method.
func (m *MockSource) Ersatz() ersatz.Return {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Ersatz")
	ret0, _ := ret[0].(ersatz.Return)
	return ret0
}

// Ersatz indicates an expected call of Ersatz.
func (mr *MockSourceMockRecorder) Ersatz() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ersatz", reflect.TypeOf((*MockSource)(nil).Ersatz))
}

// OtherErsatz mocks base method.
func (m *MockSource) OtherErsatz() ersatz0.Return {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "OtherErsatz")
	ret0, _ := ret[0].(ersatz0.Return)
	return ret0
}

// OtherErsatz indicates an expected call of OtherErsatz.
func (mr *MockSourceMockRecorder) OtherErsatz() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OtherErsatz", reflect.TypeOf((*MockSource)(nil).OtherErsatz))
}


================================================
FILE: mockgen/internal/tests/import_embedded_interface/bugreport_test.go
================================================
// Copyright 2020 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package bugreport

import (
	"testing"

	"github.com/golang/mock/gomock"
)

// TestValidInterface assesses whether or not the generated mock is valid
func TestValidInterface(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()

	s := NewMockSource(ctrl)
	s.EXPECT().Ersatz().Return("")
	s.EXPECT().OtherErsatz().Return("")
	CallForeignMethod(s)
}


================================================
FILE: mockgen/internal/tests/import_embedded_interface/ersatz/ersatz.go
================================================
// Copyright 2020 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ersatz

type Embedded interface {
	Ersatz() Return
}

type Return interface{}


================================================
FILE: mockgen/internal/tests/import_embedded_interface/faux/conflict.go
================================================
// Copyright 2020 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package faux

import "github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/other/log"

func Conflict1() {
	log.Foo()
}


================================================
FILE: mockgen/internal/tests/import_embedded_interface/faux/faux.go
================================================
// Copyright 2020 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package faux

import (
	"log"

	"github.com/golang/mock/mockgen/internal/tests/import_embedded_interface/other/ersatz"
)

type Foreign interface {
	ersatz.Embedded
}

func Conflict0() {
	log.Println()
}


================================================
FILE: mockgen/internal/tests/import_embedded_interface/foo.go
================================================
package bugreport

type Foo interface {
	Bar() Baz
}
type Baz interface{}


================================================
FILE: mockgen/internal/tests/import_embedded_interface/net.go
================================================
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package bugreport

//go:generate mockgen -destination net_mock.go -package bugreport -source=net.go

import "net/http"

type Net interface {
	http.ResponseWriter
}

func CallResponseWriterMethods(n Net) {
	n.WriteHeader(10)
}


================================================
FILE: mockgen/internal/tests/import_embedded_interface/net_mock.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: net.go

// Package bugreport is a generated GoMock package.
package bugreport

import (
	http "net/http"
	reflect "reflect"

	gomock "github.com/golang/mock/gomock"
)

// MockNet is a mock of Net interface.
type MockNet struct {
	ctrl     *gomock.Controller
	recorder *MockNetMockRecorder
}

// MockNetMockRecorder is the mock recorder for MockNet.
type MockNetMockRecorder struct {
	mock *MockNet
}

// NewMockNet creates a new mock instance.
func NewMockNet(ctrl *gomock.Controller) *MockNet {
	mock := &MockNet{ctrl: ctrl}
	mock.recorder = &MockNetMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockNet) EXPECT() *MockNetMockRecorder {
	return m.recorder
}

// Header mocks base method.
func (m *MockNet) Header() http.Header {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Header")
	ret0, _ := ret[0].(http.Header)
	return ret0
}

// Header indicates an expected call of Header.
func (mr *MockNetMockRecorder) Header() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Header", reflect.TypeOf((*MockNet)(nil).Header))
}

// Write mocks base method.
func (m *MockNet) Write(arg0 []byte) (int, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Write", arg0)
	ret0, _ := ret[0].(int)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// Write indicates an expected call of Write.
func (mr *MockNetMockRecorder) Write(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockNet)(nil).Write), arg0)
}

// WriteHeader mocks base method.
func (m *MockNet) WriteHeader(statusCode int) {
	m.ctrl.T.Helper()
	m.ctrl.Call(m, "WriteHeader", statusCode)
}

// WriteHeader indicates an expected call of WriteHeader.
func (mr *MockNetMockRecorder) WriteHeader(statusCode interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteHeader", reflect.TypeOf((*MockNet)(nil).WriteHeader), statusCode)
}


================================================
FILE: mockgen/internal/tests/import_embedded_interface/net_test.go
================================================
// Copyright 2020 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package bugreport

import (
	"testing"

	"github.com/golang/mock/gomock"
)

// TestValidInterface assesses whether or not the generated mock is valid
func TestValidNetInterface(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()

	s := NewMockNet(ctrl)
	s.EXPECT().WriteHeader(10)
	CallResponseWriterMethods(s)
}


================================================
FILE: mockgen/internal/tests/import_embedded_interface/other/ersatz/ersatz.go
================================================
// Copyright 2020 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package ersatz

type Embedded interface {
	OtherErsatz() Return
}

type Return interface{}


================================================
FILE: mockgen/internal/tests/import_embedded_interface/other/log/log.go
================================================
// Copyright 2020 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package log

func Foo() {}


================================================
FILE: mockgen/internal/tests/import_source/README.md
================================================
# Import Source

Test the case where the generated code uses a type defined in the source package (in source mode). There are two test cases:

- the output is in a new package
- the output is in the same package as the input


================================================
FILE: mockgen/internal/tests/import_source/definition/source.go
================================================
package source

//go:generate mockgen -destination ../source_mock.go -source=source.go
//go:generate mockgen -package source -destination source_mock.go -source=source.go

type X struct{}

type S interface {
	F(X)
}


================================================
FILE: mockgen/internal/tests/import_source/definition/source_mock.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: source.go

// Package source is a generated GoMock package.
package source

import (
	reflect "reflect"

	gomock "github.com/golang/mock/gomock"
)

// MockS is a mock of S interface.
type MockS struct {
	ctrl     *gomock.Controller
	recorder *MockSMockRecorder
}

// MockSMockRecorder is the mock recorder for MockS.
type MockSMockRecorder struct {
	mock *MockS
}

// NewMockS creates a new mock instance.
func NewMockS(ctrl *gomock.Controller) *MockS {
	mock := &MockS{ctrl: ctrl}
	mock.recorder = &MockSMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockS) EXPECT() *MockSMockRecorder {
	return m.recorder
}

// F mocks base method.
func (m *MockS) F(arg0 X) {
	m.ctrl.T.Helper()
	m.ctrl.Call(m, "F", arg0)
}

// F indicates an expected call of F.
func (mr *MockSMockRecorder) F(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "F", reflect.TypeOf((*MockS)(nil).F), arg0)
}


================================================
FILE: mockgen/internal/tests/import_source/source_mock.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: source.go

// Package mock_source is a generated GoMock package.
package mock_source

import (
	reflect "reflect"

	gomock "github.com/golang/mock/gomock"
	source "github.com/golang/mock/mockgen/internal/tests/import_source/definition"
)

// MockS is a mock of S interface.
type MockS struct {
	ctrl     *gomock.Controller
	recorder *MockSMockRecorder
}

// MockSMockRecorder is the mock recorder for MockS.
type MockSMockRecorder struct {
	mock *MockS
}

// NewMockS creates a new mock instance.
func NewMockS(ctrl *gomock.Controller) *MockS {
	mock := &MockS{ctrl: ctrl}
	mock.recorder = &MockSMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockS) EXPECT() *MockSMockRecorder {
	return m.recorder
}

// F mocks base method.
func (m *MockS) F(arg0 source.X) {
	m.ctrl.T.Helper()
	m.ctrl.Call(m, "F", arg0)
}

// F indicates an expected call of F.
func (mr *MockSMockRecorder) F(arg0 interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "F", reflect.TypeOf((*MockS)(nil).F), arg0)
}


================================================
FILE: mockgen/internal/tests/internal_pkg/generate.go
================================================
package test

//go:generate mockgen -destination subdir/internal/pkg/reflect_output/mock.go github.com/golang/mock/mockgen/internal/tests/internal_pkg/subdir/internal/pkg Intf
//go:generate mockgen -source subdir/internal/pkg/input.go -destination subdir/internal/pkg/source_output/mock.go


================================================
FILE: mockgen/internal/tests/internal_pkg/subdir/internal/pkg/input.go
================================================
package pkg

type Arg interface {
	Foo() int
}

type Intf interface {
	F() Arg
}


================================================
FILE: mockgen/internal/tests/internal_pkg/subdir/internal/pkg/reflect_output/mock.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/golang/mock/mockgen/internal/tests/internal_pkg/subdir/internal/pkg (interfaces: Intf)

// Package mock_pkg is a generated GoMock package.
package mock_pkg

import (
	reflect "reflect"

	gomock "github.com/golang/mock/gomock"
	pkg "github.com/golang/mock/mockgen/internal/tests/internal_pkg/subdir/internal/pkg"
)

// MockIntf is a mock of Intf interface.
type MockIntf struct {
	ctrl     *gomock.Controller
	recorder *MockIntfMockRecorder
}

// MockIntfMockRecorder is the mock recorder for MockIntf.
type MockIntfMockRecorder struct {
	mock *MockIntf
}

// NewMockIntf creates a new mock instance.
func NewMockIntf(ctrl *gomock.Controller) *MockIntf {
	mock := &MockIntf{ctrl: ctrl}
	mock.recorder = &MockIntfMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockIntf) EXPECT() *MockIntfMockRecorder {
	return m.recorder
}

// F mocks base method.
func (m *MockIntf) F() pkg.Arg {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "F")
	ret0, _ := ret[0].(pkg.Arg)
	return ret0
}

// F indicates an expected call of F.
func (mr *MockIntfMockRecorder) F() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "F", reflect.TypeOf((*MockIntf)(nil).F))
}


================================================
FILE: mockgen/internal/tests/internal_pkg/subdir/internal/pkg/source_output/mock.go
================================================
// Code generated by MockGen. DO NOT EDIT.
// Source: subdir/internal/pkg/input.go

//
Download .txt
gitextract_uystbc9u/

├── .github/
│   ├── CODEOWNERS
│   ├── ISSUE_TEMPLATE/
│   │   ├── bug_report.md
│   │   ├── config.yml
│   │   └── feature_request.md
│   └── workflows/
│       └── test.yaml
├── .gitignore
├── .goreleaser.yml
├── AUTHORS
├── CONTRIBUTING.md
├── CONTRIBUTORS
├── LICENSE
├── README.md
├── ci/
│   ├── check_panic_handling.sh
│   └── test.sh
├── go.mod
├── go.sum
├── gomock/
│   ├── call.go
│   ├── call_test.go
│   ├── callset.go
│   ├── callset_test.go
│   ├── controller.go
│   ├── controller_test.go
│   ├── doc.go
│   ├── example_test.go
│   ├── internal/
│   │   └── mock_gomock/
│   │       └── mock_matcher.go
│   ├── matchers.go
│   ├── matchers_test.go
│   └── mock_test.go
├── mockgen/
│   ├── generic_go118.go
│   ├── generic_notgo118.go
│   ├── internal/
│   │   └── tests/
│   │       ├── aux_imports_embedded_interface/
│   │       │   ├── README.md
│   │       │   ├── bugreport.go
│   │       │   ├── bugreport_mock.go
│   │       │   ├── bugreport_test.go
│   │       │   └── faux/
│   │       │       └── faux.go
│   │       ├── const_array_length/
│   │       │   ├── input.go
│   │       │   └── mock.go
│   │       ├── copyright_file/
│   │       │   ├── input.go
│   │       │   ├── mock.go
│   │       │   └── mock_copyright_header
│   │       ├── custom_package_name/
│   │       │   ├── README.md
│   │       │   ├── client/
│   │       │   │   └── v1/
│   │       │   │       └── client.go
│   │       │   ├── greeter/
│   │       │   │   ├── greeter.go
│   │       │   │   ├── greeter_mock_test.go
│   │       │   │   └── greeter_test.go
│   │       │   └── validator/
│   │       │       └── validate.go
│   │       ├── dot_imports/
│   │       │   ├── input.go
│   │       │   └── mock.go
│   │       ├── empty_interface/
│   │       │   ├── input.go
│   │       │   └── mock.go
│   │       ├── extra_import/
│   │       │   ├── import.go
│   │       │   └── mock.go
│   │       ├── generated_identifier_conflict/
│   │       │   ├── README.md
│   │       │   ├── bugreport.go
│   │       │   ├── bugreport_mock.go
│   │       │   └── bugreport_test.go
│   │       ├── generics/
│   │       │   ├── external.go
│   │       │   ├── generics.go
│   │       │   ├── go.mod
│   │       │   ├── go.sum
│   │       │   ├── other/
│   │       │   │   └── other.go
│   │       │   └── source/
│   │       │       ├── mock_external_test.go
│   │       │       └── mock_generics_test.go
│   │       ├── import_embedded_interface/
│   │       │   ├── bugreport.go
│   │       │   ├── bugreport_mock.go
│   │       │   ├── bugreport_test.go
│   │       │   ├── ersatz/
│   │       │   │   └── ersatz.go
│   │       │   ├── faux/
│   │       │   │   ├── conflict.go
│   │       │   │   └── faux.go
│   │       │   ├── foo.go
│   │       │   ├── net.go
│   │       │   ├── net_mock.go
│   │       │   ├── net_test.go
│   │       │   └── other/
│   │       │       ├── ersatz/
│   │       │       │   └── ersatz.go
│   │       │       └── log/
│   │       │           └── log.go
│   │       ├── import_source/
│   │       │   ├── README.md
│   │       │   ├── definition/
│   │       │   │   ├── source.go
│   │       │   │   └── source_mock.go
│   │       │   └── source_mock.go
│   │       ├── internal_pkg/
│   │       │   ├── generate.go
│   │       │   └── subdir/
│   │       │       └── internal/
│   │       │           └── pkg/
│   │       │               ├── input.go
│   │       │               ├── reflect_output/
│   │       │               │   └── mock.go
│   │       │               └── source_output/
│   │       │                   └── mock.go
│   │       ├── missing_import/
│   │       │   ├── output/
│   │       │   │   └── source_mock.go
│   │       │   └── source/
│   │       │       └── source.go
│   │       ├── mock_in_test_package/
│   │       │   ├── README.md
│   │       │   ├── mock_test.go
│   │       │   └── user.go
│   │       ├── overlapping_methods/
│   │       │   ├── interfaces.go
│   │       │   ├── mock.go
│   │       │   ├── overlap.go
│   │       │   └── overlap_test.go
│   │       ├── panicing_test/
│   │       │   ├── mock_test.go
│   │       │   ├── panic.go
│   │       │   └── panic_test.go
│   │       ├── parenthesized_parameter_type/
│   │       │   ├── README.md
│   │       │   ├── input.go
│   │       │   └── mock.go
│   │       ├── performance/
│   │       │   └── big_interface/
│   │       │       └── big_interface.go
│   │       ├── self_package/
│   │       │   ├── mock.go
│   │       │   └── types.go
│   │       ├── test_package/
│   │       │   ├── foo.go
│   │       │   ├── mock_test.go
│   │       │   └── user_test.go
│   │       ├── unexported_method/
│   │       │   ├── README.md
│   │       │   ├── bugreport.go
│   │       │   ├── bugreport_mock.go
│   │       │   └── bugreport_test.go
│   │       ├── vendor_dep/
│   │       │   ├── README.md
│   │       │   ├── doc.go
│   │       │   ├── mock.go
│   │       │   ├── source_mock_package/
│   │       │   │   └── mock.go
│   │       │   └── vendor_dep.go
│   │       └── vendor_pkg/
│   │           ├── README.md
│   │           ├── doc.go
│   │           └── mock.go
│   ├── mockgen.go
│   ├── mockgen_test.go
│   ├── model/
│   │   ├── model.go
│   │   └── model_test.go
│   ├── parse.go
│   ├── parse_test.go
│   ├── reflect.go
│   └── version.go
└── sample/
    ├── README.md
    ├── concurrent/
    │   ├── concurrent.go
    │   ├── concurrent_test.go
    │   └── mock/
    │       └── concurrent_mock.go
    ├── imp1/
    │   └── imp1.go
    ├── imp2/
    │   └── imp2.go
    ├── imp3/
    │   └── imp3.go
    ├── imp4/
    │   └── imp4.go
    ├── mock_user_test.go
    ├── user.go
    └── user_test.go
Download .txt
SYMBOL INDEX (775 symbols across 101 files)

FILE: gomock/call.go
  type Call (line 25) | type Call struct
    method AnyTimes (line 83) | func (c *Call) AnyTimes() *Call {
    method MinTimes (line 90) | func (c *Call) MinTimes(n int) *Call {
    method MaxTimes (line 100) | func (c *Call) MaxTimes(n int) *Call {
    method DoAndReturn (line 112) | func (c *Call) DoAndReturn(f interface{}) *Call {
    method Do (line 153) | func (c *Call) Do(f interface{}) *Call {
    method Return (line 186) | func (c *Call) Return(rets ...interface{}) *Call {
    method Times (line 226) | func (c *Call) Times(n int) *Call {
    method SetArg (line 234) | func (c *Call) SetArg(n int, value interface{}) *Call {
    method isPreReq (line 281) | func (c *Call) isPreReq(other *Call) bool {
    method After (line 291) | func (c *Call) After(preReq *Call) *Call {
    method satisfied (line 306) | func (c *Call) satisfied() bool {
    method exhausted (line 311) | func (c *Call) exhausted() bool {
    method String (line 315) | func (c *Call) String() string {
    method matches (line 326) | func (c *Call) matches(args []interface{}) error {
    method dropPrereqs (line 426) | func (c *Call) dropPrereqs() (preReqs []*Call) {
    method call (line 432) | func (c *Call) call() []func([]interface{}) []interface{} {
    method addAction (line 461) | func (c *Call) addAction(action func([]interface{}) []interface{}) {
  function newCall (line 49) | func newCall(t TestHelper, receiver interface{}, method string, methodTy...
  function InOrder (line 438) | func InOrder(calls ...*Call) {
  function setSlice (line 444) | func setSlice(arg interface{}, v reflect.Value) {
  function setMap (line 451) | func setMap(arg interface{}, v reflect.Value) {
  function formatGottenArg (line 465) | func formatGottenArg(m Matcher, arg interface{}) string {

FILE: gomock/call_test.go
  type foo (line 23) | type foo struct
    method String (line 25) | func (f foo) String() string {
  type a (line 29) | type a struct
    method Name (line 33) | func (testObj a) Name() string {
  type b (line 37) | type b struct
    method Foo (line 41) | func (testObj b) Foo() string {
  type mockTestReporter (line 45) | type mockTestReporter struct
    method Errorf (line 50) | func (o *mockTestReporter) Errorf(format string, args ...interface{}) {
    method Fatalf (line 54) | func (o *mockTestReporter) Fatalf(format string, args ...interface{}) {
    method Helper (line 58) | func (o *mockTestReporter) Helper() {}
  function TestCall_After (line 60) | func TestCall_After(t *testing.T) {
  function prepareDoCall (line 91) | func prepareDoCall(doFunc, callFunc interface{}) *Call {
  function prepareDoAndReturnCall (line 104) | func prepareDoAndReturnCall(doFunc, callFunc interface{}) *Call {
  type testCase (line 117) | type testCase struct
  function TestCall_Do (line 460) | func TestCall_Do(t *testing.T) {
  function TestCall_Do_NumArgValidation (line 484) | func TestCall_Do_NumArgValidation(t *testing.T) {
  function TestCall_DoAndReturn_NumArgValidation (line 540) | func TestCall_DoAndReturn_NumArgValidation(t *testing.T) {
  function TestCall_DoAndReturn (line 596) | func TestCall_DoAndReturn(t *testing.T) {

FILE: gomock/callset.go
  type callSet (line 25) | type callSet struct
    method Add (line 43) | func (cs callSet) Add(call *Call) {
    method Remove (line 53) | func (cs callSet) Remove(call *Call) {
    method FindMatch (line 67) | func (cs callSet) FindMatch(receiver interface{}, method string, args ...
    method Failures (line 103) | func (cs callSet) Failures() []*Call {
  type callSetKey (line 33) | type callSetKey struct
  function newCallSet (line 38) | func newCallSet() *callSet {

FILE: gomock/callset_test.go
  type receiverType (line 22) | type receiverType struct
    method Func (line 24) | func (receiverType) Func() {}
  function TestCallSetAdd (line 26) | func TestCallSetAdd(t *testing.T) {
  function TestCallSetRemove (line 45) | func TestCallSetRemove(t *testing.T) {
  function TestCallSetFindMatch (line 78) | func TestCallSetFindMatch(t *testing.T) {

FILE: gomock/controller.go
  type TestReporter (line 27) | type TestReporter interface
  type TestHelper (line 34) | type TestHelper interface
  type cleanuper (line 44) | type cleanuper interface
  type Controller (line 72) | type Controller struct
    method RecordCall (line 151) | func (ctrl *Controller) RecordCall(receiver interface{}, method string...
    method RecordCallWithMethodType (line 165) | func (ctrl *Controller) RecordCallWithMethodType(receiver interface{},...
    method Call (line 178) | func (ctrl *Controller) Call(receiver interface{}, method string, args...
    method Finish (line 227) | func (ctrl *Controller) Finish() {
    method finish (line 234) | func (ctrl *Controller) finish(cleanup bool, panicErr interface{}) {
  function NewController (line 89) | func NewController(t TestReporter) *Controller {
  type cancelReporter (line 108) | type cancelReporter struct
    method Errorf (line 113) | func (r *cancelReporter) Errorf(format string, args ...interface{}) {
    method Fatalf (line 116) | func (r *cancelReporter) Fatalf(format string, args ...interface{}) {
    method Helper (line 121) | func (r *cancelReporter) Helper() {
  function WithContext (line 127) | func WithContext(ctx context.Context, t TestReporter) (*Controller, cont...
  type nopTestHelper (line 137) | type nopTestHelper struct
    method Errorf (line 141) | func (h *nopTestHelper) Errorf(format string, args ...interface{}) {
    method Fatalf (line 144) | func (h *nopTestHelper) Fatalf(format string, args ...interface{}) {
    method Helper (line 148) | func (h nopTestHelper) Helper() {}
  function callerInfo (line 269) | func callerInfo(skip int) string {
  function isCleanuper (line 277) | func isCleanuper(t TestReporter) (cleanuper, bool) {
  function unwrapTestReporter (line 284) | func unwrapTestReporter(t TestReporter) TestReporter {

FILE: gomock/controller_test.go
  type ErrorReporter (line 27) | type ErrorReporter struct
    method reportLog (line 38) | func (e *ErrorReporter) reportLog() {
    method assertPass (line 44) | func (e *ErrorReporter) assertPass(msg string) {
    method assertFail (line 51) | func (e *ErrorReporter) assertFail(msg string) {
    method assertFatal (line 58) | func (e *ErrorReporter) assertFatal(fn func(), expectedErrMsgs ...stri...
    method recoverUnexpectedFatal (line 95) | func (e *ErrorReporter) recoverUnexpectedFatal() {
    method Log (line 110) | func (e *ErrorReporter) Log(args ...interface{}) {
    method Logf (line 114) | func (e *ErrorReporter) Logf(format string, args ...interface{}) {
    method Errorf (line 118) | func (e *ErrorReporter) Errorf(format string, args ...interface{}) {
    method Fatalf (line 123) | func (e *ErrorReporter) Fatalf(format string, args ...interface{}) {
    method Cleanup (line 847) | func (e *ErrorReporter) Cleanup(f func()) {
  function NewErrorReporter (line 34) | func NewErrorReporter(t *testing.T) *ErrorReporter {
  type HelperReporter (line 129) | type HelperReporter struct
    method Helper (line 134) | func (h *HelperReporter) Helper() {
  type Subject (line 139) | type Subject struct
    method FooMethod (line 141) | func (s *Subject) FooMethod(arg string) int {
    method BarMethod (line 145) | func (s *Subject) BarMethod(arg string) int {
    method VariadicMethod (line 149) | func (s *Subject) VariadicMethod(arg int, vararg ...string) {}
    method ActOnTestStructMethod (line 157) | func (s *Subject) ActOnTestStructMethod(arg TestStruct, arg1 int) int {
    method SetArgMethod (line 161) | func (s *Subject) SetArgMethod(sliceArg []byte, ptrArg *int, mapArg ma...
    method SetArgMethodInterface (line 162) | func (s *Subject) SetArgMethodInterface(sliceArg, ptrArg, mapArg inter...
  type TestStruct (line 152) | type TestStruct struct
  function assertEqual (line 164) | func assertEqual(t *testing.T, expected interface{}, actual interface{}) {
  function createFixtures (line 170) | func createFixtures(t *testing.T) (reporter *ErrorReporter, ctrl *gomock...
  function TestNoCalls (line 179) | func TestNoCalls(t *testing.T) {
  function TestNoRecordedCallsForAReceiver (line 185) | func TestNoRecordedCallsForAReceiver(t *testing.T) {
  function TestNoRecordedMatchingMethodNameForAReceiver (line 195) | func TestNoRecordedMatchingMethodNameForAReceiver(t *testing.T) {
  function TestExpectedMethodCall (line 210) | func TestExpectedMethodCall(t *testing.T) {
  function TestUnexpectedMethodCall (line 221) | func TestUnexpectedMethodCall(t *testing.T) {
  function TestRepeatedCall (line 232) | func TestRepeatedCall(t *testing.T) {
  function TestUnexpectedArgCount (line 248) | func TestUnexpectedArgCount(t *testing.T) {
  function TestExpectedMethodCall_CustomStruct (line 269) | func TestExpectedMethodCall_CustomStruct(t *testing.T) {
  function TestUnexpectedArgValue_FirstArg (line 280) | func TestUnexpectedArgValue_FirstArg(t *testing.T) {
  function TestUnexpectedArgValue_SecondArg (line 306) | func TestUnexpectedArgValue_SecondArg(t *testing.T) {
  function TestUnexpectedArgValue_WantFormatter (line 325) | func TestUnexpectedArgValue_WantFormatter(t *testing.T) {
  function TestUnexpectedArgValue_GotFormatter (line 352) | func TestUnexpectedArgValue_GotFormatter(t *testing.T) {
  function TestAnyTimes (line 382) | func TestAnyTimes(t *testing.T) {
  function TestMinTimes1 (line 394) | func TestMinTimes1(t *testing.T) {
  function TestMaxTimes1 (line 420) | func TestMaxTimes1(t *testing.T) {
  function TestMinMaxTimes (line 445) | func TestMinMaxTimes(t *testing.T) {
  function TestDo (line 493) | func TestDo(t *testing.T) {
  function TestDoAndReturn (line 521) | func TestDoAndReturn(t *testing.T) {
  function TestSetArgSlice (line 558) | func TestSetArgSlice(t *testing.T) {
  function TestSetArgMap (line 581) | func TestSetArgMap(t *testing.T) {
  function TestSetArgPtr (line 604) | func TestSetArgPtr(t *testing.T) {
  function TestReturn (line 626) | func TestReturn(t *testing.T) {
  function TestUnorderedCalls (line 646) | func TestUnorderedCalls(t *testing.T) {
  function commonTestOrderedCalls (line 670) | func commonTestOrderedCalls(t *testing.T) (reporter *ErrorReporter, ctrl...
  function TestOrderedCallsCorrect (line 685) | func TestOrderedCallsCorrect(t *testing.T) {
  function TestPanicOverridesExpectationChecks (line 697) | func TestPanicOverridesExpectationChecks(t *testing.T) {
  function TestSetArgWithBadType (line 708) | func TestSetArgWithBadType(t *testing.T) {
  function TestTimes0 (line 720) | func TestTimes0(t *testing.T) {
  function TestVariadicMatching (line 731) | func TestVariadicMatching(t *testing.T) {
  function TestVariadicNoMatch (line 742) | func TestVariadicNoMatch(t *testing.T) {
  function TestVariadicMatchingWithSlice (line 756) | func TestVariadicMatchingWithSlice(t *testing.T) {
  function TestVariadicArgumentsGotFormatter (line 780) | func TestVariadicArgumentsGotFormatter(t *testing.T) {
  function TestVariadicArgumentsGotFormatterTooManyArgsFailure (line 804) | func TestVariadicArgumentsGotFormatterTooManyArgsFailure(t *testing.T) {
  function TestNoHelper (line 829) | func TestNoHelper(t *testing.T) {
  function TestWithHelper (line 836) | func TestWithHelper(t *testing.T) {
  function TestMultipleDefers (line 852) | func TestMultipleDefers(t *testing.T) {
  function TestDeferNotNeededFail (line 863) | func TestDeferNotNeededFail(t *testing.T) {
  function TestDeferNotNeededPass (line 875) | func TestDeferNotNeededPass(t *testing.T) {
  function TestOrderedCallsInCorrect (line 887) | func TestOrderedCallsInCorrect(t *testing.T) {
  function TestOrderedCallsWithPreReqMaxUnbounded (line 909) | func TestOrderedCallsWithPreReqMaxUnbounded(t *testing.T) {
  function TestCallAfterLoopPanic (line 932) | func TestCallAfterLoopPanic(t *testing.T) {

FILE: gomock/example_test.go
  type Foo (line 13) | type Foo interface
  function ExampleCall_DoAndReturn_latency (line 17) | func ExampleCall_DoAndReturn_latency() {
  function ExampleCall_DoAndReturn_captureArguments (line 34) | func ExampleCall_DoAndReturn_captureArguments() {

FILE: gomock/internal/mock_gomock/mock_matcher.go
  type MockMatcher (line 14) | type MockMatcher struct
    method EXPECT (line 32) | func (m *MockMatcher) EXPECT() *MockMatcherMockRecorder {
    method Matches (line 37) | func (m *MockMatcher) Matches(arg0 interface{}) bool {
    method String (line 51) | func (m *MockMatcher) String() string {
  type MockMatcherMockRecorder (line 20) | type MockMatcherMockRecorder struct
    method Matches (line 45) | func (mr *MockMatcherMockRecorder) Matches(arg0 interface{}) *gomock.C...
    method String (line 59) | func (mr *MockMatcherMockRecorder) String() *gomock.Call {
  function NewMockMatcher (line 25) | func NewMockMatcher(ctrl *gomock.Controller) *MockMatcher {

FILE: gomock/matchers.go
  type Matcher (line 25) | type Matcher interface
  function WantFormatter (line 36) | func WantFormatter(s fmt.Stringer, m Matcher) Matcher {
  type StringerFunc (line 53) | type StringerFunc
    method String (line 56) | func (f StringerFunc) String() string {
  type GotFormatter (line 63) | type GotFormatter interface
  type GotFormatterFunc (line 72) | type GotFormatterFunc
    method Got (line 75) | func (f GotFormatterFunc) Got(got interface{}) string {
  function GotFormatterAdapter (line 80) | func GotFormatterAdapter(s GotFormatter, m Matcher) Matcher {
  type anyMatcher (line 90) | type anyMatcher struct
    method Matches (line 92) | func (anyMatcher) Matches(interface{}) bool {
    method String (line 96) | func (anyMatcher) String() string {
  type eqMatcher (line 100) | type eqMatcher struct
    method Matches (line 104) | func (e eqMatcher) Matches(x interface{}) bool {
    method String (line 122) | func (e eqMatcher) String() string {
  type nilMatcher (line 126) | type nilMatcher struct
    method Matches (line 128) | func (nilMatcher) Matches(x interface{}) bool {
    method String (line 143) | func (nilMatcher) String() string {
  type notMatcher (line 147) | type notMatcher struct
    method Matches (line 151) | func (n notMatcher) Matches(x interface{}) bool {
    method String (line 155) | func (n notMatcher) String() string {
  type assignableToTypeOfMatcher (line 159) | type assignableToTypeOfMatcher struct
    method Matches (line 163) | func (m assignableToTypeOfMatcher) Matches(x interface{}) bool {
    method String (line 167) | func (m assignableToTypeOfMatcher) String() string {
  type allMatcher (line 171) | type allMatcher struct
    method Matches (line 175) | func (am allMatcher) Matches(x interface{}) bool {
    method String (line 184) | func (am allMatcher) String() string {
  type lenMatcher (line 192) | type lenMatcher struct
    method Matches (line 196) | func (m lenMatcher) Matches(x interface{}) bool {
    method String (line 206) | func (m lenMatcher) String() string {
  type inAnyOrderMatcher (line 210) | type inAnyOrderMatcher struct
    method Matches (line 214) | func (m inAnyOrderMatcher) Matches(x interface{}) bool {
    method prepareValue (line 260) | func (m inAnyOrderMatcher) prepareValue(x interface{}) (reflect.Value,...
    method String (line 270) | func (m inAnyOrderMatcher) String() string {
  function All (line 278) | func All(ms ...Matcher) Matcher { return allMatcher{ms} }
  function Any (line 281) | func Any() Matcher { return anyMatcher{} }
  function Eq (line 288) | func Eq(x interface{}) Matcher { return eqMatcher{x} }
  function Len (line 292) | func Len(i int) Matcher {
  function Nil (line 303) | func Nil() Matcher { return nilMatcher{} }
  function Not (line 310) | func Not(x interface{}) Matcher {
  function AssignableToTypeOf (line 327) | func AssignableToTypeOf(x interface{}) Matcher {
  function InAnyOrder (line 339) | func InAnyOrder(x interface{}) Matcher {

FILE: gomock/matchers_test.go
  type A (line 29) | type A
  function TestMatchers (line 31) | func TestMatchers(t *testing.T) {
  function TestNotMatcher (line 71) | func TestNotMatcher(t *testing.T) {
  type Dog (line 89) | type Dog struct
  type ctxKey (line 93) | type ctxKey struct
  function TestAssignableToTypeOfMatcher (line 96) | func TestAssignableToTypeOfMatcher(t *testing.T) {
  function TestInAnyOrder (line 148) | func TestInAnyOrder(t *testing.T) {

FILE: gomock/mock_test.go
  type MockFoo (line 14) | type MockFoo struct
    method EXPECT (line 32) | func (m *MockFoo) EXPECT() *MockFooMockRecorder {
    method Bar (line 37) | func (m *MockFoo) Bar(arg0 string) string {
  type MockFooMockRecorder (line 20) | type MockFooMockRecorder struct
    method Bar (line 45) | func (mr *MockFooMockRecorder) Bar(arg0 interface{}) *gomock.Call {
  function NewMockFoo (line 25) | func NewMockFoo(ctrl *gomock.Controller) *MockFoo {

FILE: mockgen/generic_go118.go
  function getTypeSpecTypeParams (line 20) | func getTypeSpecTypeParams(ts *ast.TypeSpec) []*ast.Field {
  method parseGenericType (line 27) | func (p *fileParser) parseGenericType(pkg string, typ ast.Expr, tps map[...
  function getIdentTypeParams (line 67) | func getIdentTypeParams(decl interface{}) string {

FILE: mockgen/generic_notgo118.go
  function getTypeSpecTypeParams (line 26) | func getTypeSpecTypeParams(ts *ast.TypeSpec) []*ast.Field {
  method parseGenericType (line 30) | func (p *fileParser) parseGenericType(pkg string, typ ast.Expr, tps map[...
  function getIdentTypeParams (line 34) | func getIdentTypeParams(decl interface{}) string {

FILE: mockgen/internal/tests/aux_imports_embedded_interface/bugreport.go
  type Source (line 12) | type Source interface
  function CallForeignMethod (line 16) | func CallForeignMethod(s Source) {

FILE: mockgen/internal/tests/aux_imports_embedded_interface/bugreport_mock.go
  type MockSource (line 15) | type MockSource struct
    method EXPECT (line 33) | func (m *MockSource) EXPECT() *MockSourceMockRecorder {
    method Error (line 38) | func (m *MockSource) Error() string {
    method Method (line 52) | func (m *MockSource) Method() faux.Return {
  type MockSourceMockRecorder (line 21) | type MockSourceMockRecorder struct
    method Error (line 46) | func (mr *MockSourceMockRecorder) Error() *gomock.Call {
    method Method (line 60) | func (mr *MockSourceMockRecorder) Method() *gomock.Call {
  function NewMockSource (line 26) | func NewMockSource(ctrl *gomock.Controller) *MockSource {

FILE: mockgen/internal/tests/aux_imports_embedded_interface/bugreport_test.go
  function TestValidInterface (line 10) | func TestValidInterface(t *testing.T) {

FILE: mockgen/internal/tests/aux_imports_embedded_interface/faux/faux.go
  type Foreign (line 3) | type Foreign interface
  type Embedded (line 9) | type Embedded interface
  type Return (line 11) | type Return interface

FILE: mockgen/internal/tests/const_array_length/input.go
  constant C (line 7) | C = 2
  type I (line 9) | type I interface

FILE: mockgen/internal/tests/const_array_length/mock.go
  type MockI (line 14) | type MockI struct
    method EXPECT (line 32) | func (m *MockI) EXPECT() *MockIMockRecorder {
    method Bar (line 37) | func (m *MockI) Bar() [2]int {
    method Baz (line 51) | func (m *MockI) Baz() [127]int {
    method Corge (line 65) | func (m *MockI) Corge() [7]int {
    method Foo (line 79) | func (m *MockI) Foo() [2]int {
    method Quux (line 93) | func (m *MockI) Quux() [3]int {
    method Qux (line 107) | func (m *MockI) Qux() [3]int {
  type MockIMockRecorder (line 20) | type MockIMockRecorder struct
    method Bar (line 45) | func (mr *MockIMockRecorder) Bar() *gomock.Call {
    method Baz (line 59) | func (mr *MockIMockRecorder) Baz() *gomock.Call {
    method Corge (line 73) | func (mr *MockIMockRecorder) Corge() *gomock.Call {
    method Foo (line 87) | func (mr *MockIMockRecorder) Foo() *gomock.Call {
    method Quux (line 101) | func (mr *MockIMockRecorder) Quux() *gomock.Call {
    method Qux (line 115) | func (mr *MockIMockRecorder) Qux() *gomock.Call {
  function NewMockI (line 25) | func NewMockI(ctrl *gomock.Controller) *MockI {

FILE: mockgen/internal/tests/copyright_file/input.go
  type Empty (line 5) | type Empty interface

FILE: mockgen/internal/tests/copyright_file/mock.go
  type MockEmpty (line 19) | type MockEmpty struct
    method EXPECT (line 37) | func (m *MockEmpty) EXPECT() *MockEmptyMockRecorder {
  type MockEmptyMockRecorder (line 25) | type MockEmptyMockRecorder struct
  function NewMockEmpty (line 30) | func NewMockEmpty(ctrl *gomock.Controller) *MockEmpty {

FILE: mockgen/internal/tests/custom_package_name/client/v1/client.go
  type Client (line 5) | type Client struct
    method Greet (line 7) | func (c *Client) Greet(in GreetInput) string {
  type GreetInput (line 11) | type GreetInput struct

FILE: mockgen/internal/tests/custom_package_name/greeter/greeter.go
  type InputMaker (line 16) | type InputMaker interface
  type Greeter (line 20) | type Greeter struct
    method Greet (line 25) | func (g *Greeter) Greet() (string, error) {

FILE: mockgen/internal/tests/custom_package_name/greeter/greeter_mock_test.go
  type MockInputMaker (line 15) | type MockInputMaker struct
    method EXPECT (line 33) | func (m *MockInputMaker) EXPECT() *MockInputMakerMockRecorder {
    method MakeInput (line 38) | func (m *MockInputMaker) MakeInput() client.GreetInput {
  type MockInputMakerMockRecorder (line 21) | type MockInputMakerMockRecorder struct
    method MakeInput (line 46) | func (mr *MockInputMakerMockRecorder) MakeInput() *gomock.Call {
  function NewMockInputMaker (line 26) | func NewMockInputMaker(ctrl *gomock.Controller) *MockInputMaker {

FILE: mockgen/internal/tests/custom_package_name/greeter/greeter_test.go
  function TestGreeter_Greet (line 10) | func TestGreeter_Greet(t *testing.T) {

FILE: mockgen/internal/tests/custom_package_name/validator/validate.go
  function Validate (line 3) | func Validate(s string) error {

FILE: mockgen/internal/tests/dot_imports/input.go
  type WithDotImports (line 11) | type WithDotImports interface

FILE: mockgen/internal/tests/dot_imports/mock.go
  type MockWithDotImports (line 17) | type MockWithDotImports struct
    method EXPECT (line 35) | func (m *MockWithDotImports) EXPECT() *MockWithDotImportsMockRecorder {
    method Method1 (line 40) | func (m *MockWithDotImports) Method1() Request {
    method Method2 (line 54) | func (m *MockWithDotImports) Method2() *bytes.Buffer {
    method Method3 (line 68) | func (m *MockWithDotImports) Method3() Context {
  type MockWithDotImportsMockRecorder (line 23) | type MockWithDotImportsMockRecorder struct
    method Method1 (line 48) | func (mr *MockWithDotImportsMockRecorder) Method1() *gomock.Call {
    method Method2 (line 62) | func (mr *MockWithDotImportsMockRecorder) Method2() *gomock.Call {
    method Method3 (line 76) | func (mr *MockWithDotImportsMockRecorder) Method3() *gomock.Call {
  function NewMockWithDotImports (line 28) | func NewMockWithDotImports(ctrl *gomock.Controller) *MockWithDotImports {

FILE: mockgen/internal/tests/empty_interface/input.go
  type Empty (line 5) | type Empty interface

FILE: mockgen/internal/tests/empty_interface/mock.go
  type MockEmpty (line 12) | type MockEmpty struct
    method EXPECT (line 30) | func (m *MockEmpty) EXPECT() *MockEmptyMockRecorder {
  type MockEmptyMockRecorder (line 18) | type MockEmptyMockRecorder struct
  function NewMockEmpty (line 23) | func NewMockEmpty(ctrl *gomock.Controller) *MockEmpty {

FILE: mockgen/internal/tests/extra_import/import.go
  type Message (line 6) | type Message struct
  type Foo (line 10) | type Foo interface

FILE: mockgen/internal/tests/extra_import/mock.go
  type MockFoo (line 14) | type MockFoo struct
    method EXPECT (line 32) | func (m *MockFoo) EXPECT() *MockFooMockRecorder {
    method Bar (line 37) | func (m *MockFoo) Bar(arg0 []string, arg1 chan<- Message) {
  type MockFooMockRecorder (line 20) | type MockFooMockRecorder struct
    method Bar (line 43) | func (mr *MockFooMockRecorder) Bar(arg0, arg1 interface{}) *gomock.Call {
  function NewMockFoo (line 25) | func NewMockFoo(ctrl *gomock.Controller) *MockFoo {

FILE: mockgen/internal/tests/generated_identifier_conflict/bugreport.go
  type Example (line 5) | type Example interface

FILE: mockgen/internal/tests/generated_identifier_conflict/bugreport_mock.go
  type MockExample (line 14) | type MockExample struct
    method EXPECT (line 32) | func (m *MockExample) EXPECT() *MockExampleMockRecorder {
    method Method (line 37) | func (m_2 *MockExample) Method(_m, _mr, m, mr int) {
    method VarargMethod (line 49) | func (m *MockExample) VarargMethod(_s, _x, a, ret int, varargs ...int) {
  type MockExampleMockRecorder (line 20) | type MockExampleMockRecorder struct
    method Method (line 43) | func (mr_2 *MockExampleMockRecorder) Method(_m, _mr, m, mr interface{}...
    method VarargMethod (line 59) | func (mr *MockExampleMockRecorder) VarargMethod(_s, _x, a, ret interfa...
  function NewMockExample (line 25) | func NewMockExample(ctrl *gomock.Controller) *MockExample {

FILE: mockgen/internal/tests/generated_identifier_conflict/bugreport_test.go
  function TestExample_Method (line 8) | func TestExample_Method(t *testing.T) {
  function TestExample_VarargMethod (line 18) | func TestExample_VarargMethod(t *testing.T) {

FILE: mockgen/internal/tests/generics/external.go
  type ExternalConstraint (line 10) | type ExternalConstraint interface

FILE: mockgen/internal/tests/generics/generics.go
  type Bar (line 8) | type Bar interface
  type Foo (line 30) | type Foo struct
  type Baz (line 32) | type Baz struct
  type Iface (line 34) | type Iface interface
  type StructType (line 36) | type StructType struct
  type StructType2 (line 38) | type StructType2 struct
  type AliasType (line 40) | type AliasType

FILE: mockgen/internal/tests/generics/other/other.go
  type One (line 3) | type One struct
  type Two (line 5) | type Two struct
  type Three (line 7) | type Three struct
  type Four (line 9) | type Four struct
  type Five (line 11) | type Five interface

FILE: mockgen/internal/tests/generics/source/mock_external_test.go
  type MockExternalConstraint (line 17) | type MockExternalConstraint struct
  type MockExternalConstraintMockRecorder (line 23) | type MockExternalConstraintMockRecorder struct
  function NewMockExternalConstraint (line 28) | func NewMockExternalConstraint[I constraints.Integer, F constraints.Floa...
  method EXPECT (line 35) | func (m *MockExternalConstraint[I, F]) EXPECT() *MockExternalConstraintM...
  method Eight (line 40) | func (m *MockExternalConstraint[I, F]) Eight(arg0 F) other.Two[I, F] {
  method Eight (line 48) | func (mr *MockExternalConstraintMockRecorder[I, F]) Eight(arg0 interface...
  method Five (line 54) | func (m *MockExternalConstraint[I, F]) Five(arg0 I) generics.Baz[F] {
  method Five (line 62) | func (mr *MockExternalConstraintMockRecorder[I, F]) Five(arg0 interface{...
  method Four (line 68) | func (m *MockExternalConstraint[I, F]) Four(arg0 I) generics.Foo[I, F] {
  method Four (line 76) | func (mr *MockExternalConstraintMockRecorder[I, F]) Four(arg0 interface{...
  method Nine (line 82) | func (m *MockExternalConstraint[I, F]) Nine(arg0 generics.Iface[I]) {
  method Nine (line 88) | func (mr *MockExternalConstraintMockRecorder[I, F]) Nine(arg0 interface{...
  method One (line 94) | func (m *MockExternalConstraint[I, F]) One(arg0 string) string {
  method One (line 102) | func (mr *MockExternalConstraintMockRecorder[I, F]) One(arg0 interface{}...
  method Seven (line 108) | func (m *MockExternalConstraint[I, F]) Seven(arg0 I) other.One[I] {
  method Seven (line 116) | func (mr *MockExternalConstraintMockRecorder[I, F]) Seven(arg0 interface...
  method Six (line 122) | func (m *MockExternalConstraint[I, F]) Six(arg0 I) *generics.Baz[F] {
  method Six (line 130) | func (mr *MockExternalConstraintMockRecorder[I, F]) Six(arg0 interface{}...
  method Ten (line 136) | func (m *MockExternalConstraint[I, F]) Ten(arg0 *I) {
  method Ten (line 142) | func (mr *MockExternalConstraintMockRecorder[I, F]) Ten(arg0 interface{}...
  method Three (line 148) | func (m *MockExternalConstraint[I, F]) Three(arg0 I) F {
  method Three (line 156) | func (mr *MockExternalConstraintMockRecorder[I, F]) Three(arg0 interface...
  method Two (line 162) | func (m *MockExternalConstraint[I, F]) Two(arg0 I) string {
  method Two (line 170) | func (mr *MockExternalConstraintMockRecorder[I, F]) Two(arg0 interface{}...

FILE: mockgen/internal/tests/generics/source/mock_generics_test.go
  type MockBar (line 16) | type MockBar struct
  type MockBarMockRecorder (line 22) | type MockBarMockRecorder struct
  function NewMockBar (line 27) | func NewMockBar[T any, R any](ctrl *gomock.Controller) *MockBar[T, R] {
  method EXPECT (line 34) | func (m *MockBar[T, R]) EXPECT() *MockBarMockRecorder[T, R] {
  method Eight (line 39) | func (m *MockBar[T, R]) Eight(arg0 T) other.Two[T, R] {
  method Eight (line 47) | func (mr *MockBarMockRecorder[T, R]) Eight(arg0 interface{}) *gomock.Call {
  method Eighteen (line 53) | func (m *MockBar[T, R]) Eighteen() (generics.Iface[*other.Five], error) {
  method Eighteen (line 62) | func (mr *MockBarMockRecorder[T, R]) Eighteen() *gomock.Call {
  method Eleven (line 68) | func (m *MockBar[T, R]) Eleven() (*other.One[T], error) {
  method Eleven (line 77) | func (mr *MockBarMockRecorder[T, R]) Eleven() *gomock.Call {
  method Fifteen (line 83) | func (m *MockBar[T, R]) Fifteen() (generics.Iface[generics.StructType], ...
  method Fifteen (line 92) | func (mr *MockBarMockRecorder[T, R]) Fifteen() *gomock.Call {
  method Five (line 98) | func (m *MockBar[T, R]) Five(arg0 T) generics.Baz[T] {
  method Five (line 106) | func (mr *MockBarMockRecorder[T, R]) Five(arg0 interface{}) *gomock.Call {
  method Four (line 112) | func (m *MockBar[T, R]) Four(arg0 T) generics.Foo[T, R] {
  method Four (line 120) | func (mr *MockBarMockRecorder[T, R]) Four(arg0 interface{}) *gomock.Call {
  method Fourteen (line 126) | func (m *MockBar[T, R]) Fourteen() (*generics.Foo[generics.StructType, g...
  method Fourteen (line 135) | func (mr *MockBarMockRecorder[T, R]) Fourteen() *gomock.Call {
  method Nine (line 141) | func (m *MockBar[T, R]) Nine(arg0 generics.Iface[T]) {
  method Nine (line 147) | func (mr *MockBarMockRecorder[T, R]) Nine(arg0 interface{}) *gomock.Call {
  method Nineteen (line 153) | func (m *MockBar[T, R]) Nineteen() generics.AliasType {
  method Nineteen (line 161) | func (mr *MockBarMockRecorder[T, R]) Nineteen() *gomock.Call {
  method One (line 167) | func (m *MockBar[T, R]) One(arg0 string) string {
  method One (line 175) | func (mr *MockBarMockRecorder[T, R]) One(arg0 interface{}) *gomock.Call {
  method Seven (line 181) | func (m *MockBar[T, R]) Seven(arg0 T) other.One[T] {
  method Seven (line 189) | func (mr *MockBarMockRecorder[T, R]) Seven(arg0 interface{}) *gomock.Call {
  method Seventeen (line 195) | func (m *MockBar[T, R]) Seventeen() (*generics.Foo[other.Three, other.Fo...
  method Seventeen (line 204) | func (mr *MockBarMockRecorder[T, R]) Seventeen() *gomock.Call {
  method Six (line 210) | func (m *MockBar[T, R]) Six(arg0 T) *generics.Baz[T] {
  method Six (line 218) | func (mr *MockBarMockRecorder[T, R]) Six(arg0 interface{}) *gomock.Call {
  method Sixteen (line 224) | func (m *MockBar[T, R]) Sixteen() (generics.Baz[other.Three], error) {
  method Sixteen (line 233) | func (mr *MockBarMockRecorder[T, R]) Sixteen() *gomock.Call {
  method Ten (line 239) | func (m *MockBar[T, R]) Ten(arg0 *T) {
  method Ten (line 245) | func (mr *MockBarMockRecorder[T, R]) Ten(arg0 interface{}) *gomock.Call {
  method Thirteen (line 251) | func (m *MockBar[T, R]) Thirteen() (generics.Baz[generics.StructType], e...
  method Thirteen (line 260) | func (mr *MockBarMockRecorder[T, R]) Thirteen() *gomock.Call {
  method Three (line 266) | func (m *MockBar[T, R]) Three(arg0 T) R {
  method Three (line 274) | func (mr *MockBarMockRecorder[T, R]) Three(arg0 interface{}) *gomock.Call {
  method Twelve (line 280) | func (m *MockBar[T, R]) Twelve() (*other.Two[T, R], error) {
  method Twelve (line 289) | func (mr *MockBarMockRecorder[T, R]) Twelve() *gomock.Call {
  method Two (line 295) | func (m *MockBar[T, R]) Two(arg0 T) string {
  method Two (line 303) | func (mr *MockBarMockRecorder[T, R]) Two(arg0 interface{}) *gomock.Call {
  type MockIface (line 309) | type MockIface struct
  type MockIfaceMockRecorder (line 315) | type MockIfaceMockRecorder struct
  function NewMockIface (line 320) | func NewMockIface[T any](ctrl *gomock.Controller) *MockIface[T] {
  method EXPECT (line 327) | func (m *MockIface[T]) EXPECT() *MockIfaceMockRecorder[T] {

FILE: mockgen/internal/tests/import_embedded_interface/bugreport.go
  type Source (line 27) | type Source interface
  function CallForeignMethod (line 34) | func CallForeignMethod(s Source) {

FILE: mockgen/internal/tests/import_embedded_interface/bugreport_mock.go
  type MockSource (line 16) | type MockSource struct
    method EXPECT (line 34) | func (m *MockSource) EXPECT() *MockSourceMockRecorder {
    method Bar (line 39) | func (m *MockSource) Bar() Baz {
    method Error (line 53) | func (m *MockSource) Error() string {
    method Ersatz (line 67) | func (m *MockSource) Ersatz() ersatz.Return {
    method OtherErsatz (line 81) | func (m *MockSource) OtherErsatz() ersatz0.Return {
  type MockSourceMockRecorder (line 22) | type MockSourceMockRecorder struct
    method Bar (line 47) | func (mr *MockSourceMockRecorder) Bar() *gomock.Call {
    method Error (line 61) | func (mr *MockSourceMockRecorder) Error() *gomock.Call {
    method Ersatz (line 75) | func (mr *MockSourceMockRecorder) Ersatz() *gomock.Call {
    method OtherErsatz (line 89) | func (mr *MockSourceMockRecorder) OtherErsatz() *gomock.Call {
  function NewMockSource (line 27) | func NewMockSource(ctrl *gomock.Controller) *MockSource {

FILE: mockgen/internal/tests/import_embedded_interface/bugreport_test.go
  function TestValidInterface (line 23) | func TestValidInterface(t *testing.T) {

FILE: mockgen/internal/tests/import_embedded_interface/ersatz/ersatz.go
  type Embedded (line 16) | type Embedded interface
  type Return (line 20) | type Return interface

FILE: mockgen/internal/tests/import_embedded_interface/faux/conflict.go
  function Conflict1 (line 18) | func Conflict1() {

FILE: mockgen/internal/tests/import_embedded_interface/faux/faux.go
  type Foreign (line 22) | type Foreign interface
  function Conflict0 (line 26) | func Conflict0() {

FILE: mockgen/internal/tests/import_embedded_interface/foo.go
  type Foo (line 3) | type Foo interface
  type Baz (line 6) | type Baz interface

FILE: mockgen/internal/tests/import_embedded_interface/net.go
  type Net (line 20) | type Net interface
  function CallResponseWriterMethods (line 24) | func CallResponseWriterMethods(n Net) {

FILE: mockgen/internal/tests/import_embedded_interface/net_mock.go
  type MockNet (line 15) | type MockNet struct
    method EXPECT (line 33) | func (m *MockNet) EXPECT() *MockNetMockRecorder {
    method Header (line 38) | func (m *MockNet) Header() http.Header {
    method Write (line 52) | func (m *MockNet) Write(arg0 []byte) (int, error) {
    method WriteHeader (line 67) | func (m *MockNet) WriteHeader(statusCode int) {
  type MockNetMockRecorder (line 21) | type MockNetMockRecorder struct
    method Header (line 46) | func (mr *MockNetMockRecorder) Header() *gomock.Call {
    method Write (line 61) | func (mr *MockNetMockRecorder) Write(arg0 interface{}) *gomock.Call {
    method WriteHeader (line 73) | func (mr *MockNetMockRecorder) WriteHeader(statusCode interface{}) *go...
  function NewMockNet (line 26) | func NewMockNet(ctrl *gomock.Controller) *MockNet {

FILE: mockgen/internal/tests/import_embedded_interface/net_test.go
  function TestValidNetInterface (line 23) | func TestValidNetInterface(t *testing.T) {

FILE: mockgen/internal/tests/import_embedded_interface/other/ersatz/ersatz.go
  type Embedded (line 16) | type Embedded interface
  type Return (line 20) | type Return interface

FILE: mockgen/internal/tests/import_embedded_interface/other/log/log.go
  function Foo (line 16) | func Foo() {}

FILE: mockgen/internal/tests/import_source/definition/source.go
  type X (line 6) | type X struct
  type S (line 8) | type S interface

FILE: mockgen/internal/tests/import_source/definition/source_mock.go
  type MockS (line 14) | type MockS struct
    method EXPECT (line 32) | func (m *MockS) EXPECT() *MockSMockRecorder {
    method F (line 37) | func (m *MockS) F(arg0 X) {
  type MockSMockRecorder (line 20) | type MockSMockRecorder struct
    method F (line 43) | func (mr *MockSMockRecorder) F(arg0 interface{}) *gomock.Call {
  function NewMockS (line 25) | func NewMockS(ctrl *gomock.Controller) *MockS {

FILE: mockgen/internal/tests/import_source/source_mock.go
  type MockS (line 15) | type MockS struct
    method EXPECT (line 33) | func (m *MockS) EXPECT() *MockSMockRecorder {
    method F (line 38) | func (m *MockS) F(arg0 source.X) {
  type MockSMockRecorder (line 21) | type MockSMockRecorder struct
    method F (line 44) | func (mr *MockSMockRecorder) F(arg0 interface{}) *gomock.Call {
  function NewMockS (line 26) | func NewMockS(ctrl *gomock.Controller) *MockS {

FILE: mockgen/internal/tests/internal_pkg/subdir/internal/pkg/input.go
  type Arg (line 3) | type Arg interface
  type Intf (line 7) | type Intf interface

FILE: mockgen/internal/tests/internal_pkg/subdir/internal/pkg/reflect_output/mock.go
  type MockIntf (line 15) | type MockIntf struct
    method EXPECT (line 33) | func (m *MockIntf) EXPECT() *MockIntfMockRecorder {
    method F (line 38) | func (m *MockIntf) F() pkg.Arg {
  type MockIntfMockRecorder (line 21) | type MockIntfMockRecorder struct
    method F (line 46) | func (mr *MockIntfMockRecorder) F() *gomock.Call {
  function NewMockIntf (line 26) | func NewMockIntf(ctrl *gomock.Controller) *MockIntf {

FILE: mockgen/internal/tests/internal_pkg/subdir/internal/pkg/source_output/mock.go
  type MockArg (line 15) | type MockArg struct
    method EXPECT (line 33) | func (m *MockArg) EXPECT() *MockArgMockRecorder {
    method Foo (line 38) | func (m *MockArg) Foo() int {
  type MockArgMockRecorder (line 21) | type MockArgMockRecorder struct
    method Foo (line 46) | func (mr *MockArgMockRecorder) Foo() *gomock.Call {
  function NewMockArg (line 26) | func NewMockArg(ctrl *gomock.Controller) *MockArg {
  type MockIntf (line 52) | type MockIntf struct
    method EXPECT (line 70) | func (m *MockIntf) EXPECT() *MockIntfMockRecorder {
    method F (line 75) | func (m *MockIntf) F() pkg.Arg {
  type MockIntfMockRecorder (line 58) | type MockIntfMockRecorder struct
    method F (line 83) | func (mr *MockIntfMockRecorder) F() *gomock.Call {
  function NewMockIntf (line 63) | func NewMockIntf(ctrl *gomock.Controller) *MockIntf {

FILE: mockgen/internal/tests/missing_import/output/source_mock.go
  type MockBar (line 15) | type MockBar struct
    method EXPECT (line 33) | func (m *MockBar) EXPECT() *MockBarMockRecorder {
    method Baz (line 38) | func (m *MockBar) Baz(arg0 source.Foo) {
  type MockBarMockRecorder (line 21) | type MockBarMockRecorder struct
    method Baz (line 44) | func (mr *MockBarMockRecorder) Baz(arg0 interface{}) *gomock.Call {
  function NewMockBar (line 26) | func NewMockBar(ctrl *gomock.Controller) *MockBar {

FILE: mockgen/internal/tests/missing_import/source/source.go
  type Foo (line 6) | type Foo struct
  type Bar (line 8) | type Bar interface

FILE: mockgen/internal/tests/mock_in_test_package/mock_test.go
  type MockFinder (line 15) | type MockFinder struct
    method EXPECT (line 33) | func (m *MockFinder) EXPECT() *MockFinderMockRecorder {
    method Add (line 38) | func (m *MockFinder) Add(u users.User) {
    method FindUser (line 50) | func (m *MockFinder) FindUser(name string) users.User {
  type MockFinderMockRecorder (line 21) | type MockFinderMockRecorder struct
    method Add (line 44) | func (mr *MockFinderMockRecorder) Add(u interface{}) *gomock.Call {
    method FindUser (line 58) | func (mr *MockFinderMockRecorder) FindUser(name interface{}) *gomock.C...
  function NewMockFinder (line 26) | func NewMockFinder(ctrl *gomock.Controller) *MockFinder {

FILE: mockgen/internal/tests/mock_in_test_package/user.go
  type User (line 5) | type User struct
  type Finder (line 9) | type Finder interface

FILE: mockgen/internal/tests/overlapping_methods/interfaces.go
  type ReadCloser (line 3) | type ReadCloser interface
  type WriteCloser (line 8) | type WriteCloser interface

FILE: mockgen/internal/tests/overlapping_methods/mock.go
  type MockReadWriteCloser (line 14) | type MockReadWriteCloser struct
    method EXPECT (line 32) | func (m *MockReadWriteCloser) EXPECT() *MockReadWriteCloserMockRecorder {
    method Close (line 37) | func (m *MockReadWriteCloser) Close() error {
    method Read (line 51) | func (m *MockReadWriteCloser) Read(arg0 []byte) (int, error) {
    method Write (line 66) | func (m *MockReadWriteCloser) Write(arg0 []byte) (int, error) {
  type MockReadWriteCloserMockRecorder (line 20) | type MockReadWriteCloserMockRecorder struct
    method Close (line 45) | func (mr *MockReadWriteCloserMockRecorder) Close() *gomock.Call {
    method Read (line 60) | func (mr *MockReadWriteCloserMockRecorder) Read(arg0 interface{}) *gom...
    method Write (line 75) | func (mr *MockReadWriteCloserMockRecorder) Write(arg0 interface{}) *go...
  function NewMockReadWriteCloser (line 25) | func NewMockReadWriteCloser(ctrl *gomock.Controller) *MockReadWriteCloser {

FILE: mockgen/internal/tests/overlapping_methods/overlap.go
  type ReadWriteCloser (line 5) | type ReadWriteCloser interface

FILE: mockgen/internal/tests/overlapping_methods/overlap_test.go
  function TestValidInterface (line 11) | func TestValidInterface(t *testing.T) {

FILE: mockgen/internal/tests/panicing_test/mock_test.go
  type MockFoo (line 14) | type MockFoo struct
    method EXPECT (line 32) | func (m *MockFoo) EXPECT() *MockFooMockRecorder {
    method Bar (line 37) | func (m *MockFoo) Bar() string {
    method Baz (line 51) | func (m *MockFoo) Baz() string {
  type MockFooMockRecorder (line 20) | type MockFooMockRecorder struct
    method Bar (line 45) | func (mr *MockFooMockRecorder) Bar() *gomock.Call {
    method Baz (line 59) | func (mr *MockFooMockRecorder) Baz() *gomock.Call {
  function NewMockFoo (line 25) | func NewMockFoo(ctrl *gomock.Controller) *MockFoo {

FILE: mockgen/internal/tests/panicing_test/panic.go
  type Foo (line 19) | type Foo interface
  function Danger (line 24) | func Danger(f Foo) {

FILE: mockgen/internal/tests/panicing_test/panic_test.go
  function TestDanger_Panics_Explicit (line 26) | func TestDanger_Panics_Explicit(t *testing.T) {
  function TestDanger_Panics_Implicit (line 35) | func TestDanger_Panics_Implicit(t *testing.T) {

FILE: mockgen/internal/tests/parenthesized_parameter_type/input.go
  type Example (line 3) | type Example interface

FILE: mockgen/internal/tests/parenthesized_parameter_type/mock.go
  type MockExample (line 13) | type MockExample struct
    method EXPECT (line 31) | func (m *MockExample) EXPECT() *MockExampleMockRecorder {
    method ParenthesizedParameterType (line 36) | func (m *MockExample) ParenthesizedParameterType(param *int) {
  type MockExampleMockRecorder (line 19) | type MockExampleMockRecorder struct
    method ParenthesizedParameterType (line 42) | func (mr *MockExampleMockRecorder) ParenthesizedParameterType(param in...
  function NewMockExample (line 24) | func NewMockExample(ctrl *gomock.Controller) *MockExample {

FILE: mockgen/internal/tests/performance/big_interface/big_interface.go
  type Bar (line 3) | type Bar struct
  type BigInterface (line 5) | type BigInterface interface

FILE: mockgen/internal/tests/self_package/mock.go
  type MockMethods (line 14) | type MockMethods struct
    method EXPECT (line 32) | func (m *MockMethods) EXPECT() *MockMethodsMockRecorder {
    method getInfo (line 37) | func (m *MockMethods) getInfo() Info {
  type MockMethodsMockRecorder (line 20) | type MockMethodsMockRecorder struct
    method getInfo (line 45) | func (mr *MockMethodsMockRecorder) getInfo() *gomock.Call {
  function NewMockMethods (line 25) | func NewMockMethods(ctrl *gomock.Controller) *MockMethods {

FILE: mockgen/internal/tests/self_package/types.go
  type Info (line 5) | type Info struct
  type Methods (line 7) | type Methods interface

FILE: mockgen/internal/tests/test_package/mock_test.go
  type MockFinder (line 14) | type MockFinder struct
    method EXPECT (line 32) | func (m *MockFinder) EXPECT() *MockFinderMockRecorder {
    method Add (line 37) | func (m *MockFinder) Add(u User) {
    method FindUser (line 49) | func (m *MockFinder) FindUser(name string) User {
  type MockFinderMockRecorder (line 20) | type MockFinderMockRecorder struct
    method Add (line 43) | func (mr *MockFinderMockRecorder) Add(u interface{}) *gomock.Call {
    method FindUser (line 57) | func (mr *MockFinderMockRecorder) FindUser(name interface{}) *gomock.C...
  function NewMockFinder (line 25) | func NewMockFinder(ctrl *gomock.Controller) *MockFinder {

FILE: mockgen/internal/tests/test_package/user_test.go
  type User (line 5) | type User struct
  type Finder (line 9) | type Finder interface

FILE: mockgen/internal/tests/unexported_method/bugreport.go
  type Example (line 8) | type Example interface
  function CallExample (line 13) | func CallExample(e Example) {

FILE: mockgen/internal/tests/unexported_method/bugreport_mock.go
  type MockExample (line 14) | type MockExample struct
    method EXPECT (line 32) | func (m *MockExample) EXPECT() *MockExampleMockRecorder {
    method someMethod (line 37) | func (m *MockExample) someMethod(arg0 string) string {
  type MockExampleMockRecorder (line 20) | type MockExampleMockRecorder struct
    method someMethod (line 45) | func (mr *MockExampleMockRecorder) someMethod(arg0 interface{}) *gomoc...
  function NewMockExample (line 25) | func NewMockExample(ctrl *gomock.Controller) *MockExample {

FILE: mockgen/internal/tests/unexported_method/bugreport_test.go
  function TestCallExample (line 9) | func TestCallExample(t *testing.T) {

FILE: mockgen/internal/tests/vendor_dep/mock.go
  type MockVendorsDep (line 15) | type MockVendorsDep struct
    method EXPECT (line 33) | func (m *MockVendorsDep) EXPECT() *MockVendorsDepMockRecorder {
    method Foo (line 38) | func (m *MockVendorsDep) Foo() present.Elem {
  type MockVendorsDepMockRecorder (line 21) | type MockVendorsDepMockRecorder struct
    method Foo (line 46) | func (mr *MockVendorsDepMockRecorder) Foo() *gomock.Call {
  function NewMockVendorsDep (line 26) | func NewMockVendorsDep(ctrl *gomock.Controller) *MockVendorsDep {

FILE: mockgen/internal/tests/vendor_dep/source_mock_package/mock.go
  type MockVendorsDep (line 15) | type MockVendorsDep struct
    method EXPECT (line 33) | func (m *MockVendorsDep) EXPECT() *MockVendorsDepMockRecorder {
    method Foo (line 38) | func (m *MockVendorsDep) Foo() present.Elem {
  type MockVendorsDepMockRecorder (line 21) | type MockVendorsDepMockRecorder struct
    method Foo (line 46) | func (mr *MockVendorsDepMockRecorder) Foo() *gomock.Call {
  function NewMockVendorsDep (line 26) | func NewMockVendorsDep(ctrl *gomock.Controller) *MockVendorsDep {

FILE: mockgen/internal/tests/vendor_dep/vendor_dep.go
  type VendorsDep (line 5) | type VendorsDep interface

FILE: mockgen/internal/tests/vendor_pkg/mock.go
  type MockElem (line 14) | type MockElem struct
    method EXPECT (line 32) | func (m *MockElem) EXPECT() *MockElemMockRecorder {
    method TemplateName (line 37) | func (m *MockElem) TemplateName() string {
  type MockElemMockRecorder (line 20) | type MockElemMockRecorder struct
    method TemplateName (line 45) | func (mr *MockElemMockRecorder) TemplateName() *gomock.Call {
  function NewMockElem (line 25) | func NewMockElem(ctrl *gomock.Controller) *MockElem {

FILE: mockgen/mockgen.go
  constant gomockImportPath (line 47) | gomockImportPath = "github.com/golang/mock/gomock"
  function main (line 69) | func main() {
  function parseMockNames (line 187) | func parseMockNames(names string) map[string]string {
  function usage (line 199) | func usage() {
  constant usageText (line 204) | usageText = `mockgen has two modes of operation: source and reflect.
  type generator (line 221) | type generator struct
    method p (line 233) | func (g *generator) p(format string, args ...interface{}) {
    method in (line 237) | func (g *generator) in() {
    method out (line 241) | func (g *generator) out() {
    method Generate (line 270) | func (g *generator) Generate(pkg *model.Package, outputPkgName string,...
    method mockName (line 374) | func (g *generator) mockName(typeName string) string {
    method formattedTypeParams (line 386) | func (g *generator) formattedTypeParams(it *model.Interface, pkgOverri...
    method GenerateMockInterface (line 407) | func (g *generator) GenerateMockInterface(intf *model.Interface, outpu...
    method GenerateMockMethods (line 458) | func (g *generator) GenerateMockMethods(mockType string, intf *model.I...
    method GenerateMockMethod (line 483) | func (g *generator) GenerateMockMethod(mockType string, m *model.Metho...
    method GenerateMockRecorderMethod (line 548) | func (g *generator) GenerateMockRecorderMethod(mockType string, m *mod...
    method getArgNames (line 602) | func (g *generator) getArgNames(m *model.Method) []string {
    method getArgTypes (line 621) | func (g *generator) getArgTypes(m *model.Method, pkgOverride string) [...
    method Output (line 654) | func (g *generator) Output() []byte {
  function sanitize (line 248) | func sanitize(s string) string {
  type byMethodName (line 452) | type byMethodName
    method Len (line 454) | func (b byMethodName) Len() int           { return len(b) }
    method Swap (line 455) | func (b byMethodName) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }
    method Less (line 456) | func (b byMethodName) Less(i, j int) bool { return b[i].Name < b[j].Na...
  function makeArgString (line 468) | func makeArgString(argNames, argTypes []string) string {
  type identifierAllocator (line 632) | type identifierAllocator
    method allocateIdentifier (line 642) | func (o identifierAllocator) allocateIdentifier(want string) string {
  function newIdentifierAllocator (line 634) | func newIdentifierAllocator(taken []string) identifierAllocator {
  function createPackageMap (line 664) | func createPackageMap(importPaths []string) map[string]string {
  function printVersion (line 688) | func printVersion() {
  function parsePackageImport (line 701) | func parsePackageImport(srcDir string) (string, error) {

FILE: mockgen/mockgen_test.go
  function TestMakeArgString (line 16) | func TestMakeArgString(t *testing.T) {
  function TestNewIdentifierAllocator (line 119) | func TestNewIdentifierAllocator(t *testing.T) {
  function allocatorContainsIdentifiers (line 136) | func allocatorContainsIdentifiers(a identifierAllocator, ids []string) b...
  function TestIdentifierAllocator_allocateIdentifier (line 151) | func TestIdentifierAllocator_allocateIdentifier(t *testing.T) {
  function TestGenerateMockInterface_Helper (line 191) | func TestGenerateMockInterface_Helper(t *testing.T) {
  function findMethod (line 264) | func findMethod(t *testing.T, identifier, methodName string, lines []str...
  function TestGetArgNames (line 277) | func TestGetArgNames(t *testing.T) {
  function Test_createPackageMap (line 343) | func Test_createPackageMap(t *testing.T) {
  function TestParsePackageImport_FallbackGoPath (line 371) | func TestParsePackageImport_FallbackGoPath(t *testing.T) {
  function TestParsePackageImport_FallbackMultiGoPath (line 403) | func TestParsePackageImport_FallbackMultiGoPath(t *testing.T) {

FILE: mockgen/model/model.go
  constant pkgPath (line 27) | pkgPath = "github.com/golang/mock/mockgen/model"
  type Package (line 30) | type Package struct
    method Print (line 38) | func (pkg *Package) Print(w io.Writer) {
    method Imports (line 46) | func (pkg *Package) Imports() map[string]bool {
  type Interface (line 58) | type Interface struct
    method Print (line 65) | func (intf *Interface) Print(w io.Writer) {
    method addImports (line 72) | func (intf *Interface) addImports(im map[string]bool) {
    method AddMethod (line 79) | func (intf *Interface) AddMethod(m *Method) {
  type Method (line 89) | type Method struct
    method Print (line 96) | func (m *Method) Print(w io.Writer) {
    method addImports (line 116) | func (m *Method) addImports(im map[string]bool) {
  type Parameter (line 129) | type Parameter struct
    method Print (line 135) | func (p *Parameter) Print(w io.Writer) {
  type Type (line 144) | type Type interface
  function init (line 149) | func init() {
  type ArrayType (line 168) | type ArrayType struct
    method String (line 173) | func (at *ArrayType) String(pm map[string]string, pkgOverride string) ...
    method addImports (line 181) | func (at *ArrayType) addImports(im map[string]bool) { at.Type.addImpor...
  type ChanType (line 184) | type ChanType struct
    method String (line 189) | func (ct *ChanType) String(pm map[string]string, pkgOverride string) s...
    method addImports (line 200) | func (ct *ChanType) addImports(im map[string]bool) { ct.Type.addImport...
  type ChanDir (line 203) | type ChanDir
  constant RecvDir (line 207) | RecvDir ChanDir = 1
  constant SendDir (line 208) | SendDir ChanDir = 2
  type FuncType (line 212) | type FuncType struct
    method String (line 217) | func (ft *FuncType) String(pm map[string]string, pkgOverride string) s...
    method addImports (line 238) | func (ft *FuncType) addImports(im map[string]bool) {
  type MapType (line 251) | type MapType struct
    method String (line 255) | func (mt *MapType) String(pm map[string]string, pkgOverride string) st...
    method addImports (line 259) | func (mt *MapType) addImports(im map[string]bool) {
  type NamedType (line 265) | type NamedType struct
    method String (line 271) | func (nt *NamedType) String(pm map[string]string, pkgOverride string) ...
    method addImports (line 283) | func (nt *NamedType) addImports(im map[string]bool) {
  type PointerType (line 291) | type PointerType struct
    method String (line 295) | func (pt *PointerType) String(pm map[string]string, pkgOverride string...
    method addImports (line 298) | func (pt *PointerType) addImports(im map[string]bool) { pt.Type.addImp...
  type PredeclaredType (line 301) | type PredeclaredType
    method String (line 303) | func (pt PredeclaredType) String(map[string]string, string) string { r...
    method addImports (line 304) | func (pt PredeclaredType) addImports(map[string]bool)              {}
  type TypeParametersType (line 307) | type TypeParametersType struct
    method String (line 311) | func (tp *TypeParametersType) String(pm map[string]string, pkgOverride...
    method addImports (line 327) | func (tp *TypeParametersType) addImports(im map[string]bool) {
  function InterfaceFromInterfaceType (line 340) | func InterfaceFromInterfaceType(it reflect.Type) (*Interface, error) {
  function funcArgsFromType (line 366) | func funcArgsFromType(t reflect.Type) (in []*Parameter, variadic *Parame...
  function parameterFromType (line 396) | func parameterFromType(t reflect.Type) (*Parameter, error) {
  function typeFromType (line 408) | func typeFromType(t reflect.Type) (Type, error) {
  function impPath (line 507) | func impPath(imp string) string {

FILE: mockgen/model/model_test.go
  function TestImpPath (line 8) | func TestImpPath(t *testing.T) {

FILE: mockgen/parse.go
  function sourceMode (line 45) | func sourceMode(source string) (*model.Package, error) {
  type importedPackage (line 100) | type importedPackage interface
  type importedPkg (line 105) | type importedPkg struct
    method Path (line 110) | func (i importedPkg) Path() string        { return i.path }
    method Parser (line 111) | func (i importedPkg) Parser() *fileParser { return i.parser }
  type duplicateImport (line 118) | type duplicateImport struct
    method Error (line 123) | func (d duplicateImport) Error() string {
    method Path (line 127) | func (d duplicateImport) Path() string        { log.Fatal(d.Error()); ...
    method Parser (line 128) | func (d duplicateImport) Parser() *fileParser { log.Fatal(d.Error()); ...
  type interfaceCache (line 130) | type interfaceCache struct
    method Set (line 140) | func (i *interfaceCache) Set(pkg, name string, it *namedInterface) {
    method Get (line 147) | func (i *interfaceCache) Get(pkg, name string) *namedInterface {
    method GetASTIface (line 154) | func (i *interfaceCache) GetASTIface(pkg, name string) *ast.InterfaceT...
  function newInterfaceCache (line 134) | func newInterfaceCache() *interfaceCache {
  type fileParser (line 165) | type fileParser struct
    method errorf (line 174) | func (p *fileParser) errorf(pos token.Pos, format string, args ...inte...
    method parseAuxFiles (line 181) | func (p *fileParser) parseAuxFiles(auxFiles string) error {
    method addAuxInterfacesFromFile (line 203) | func (p *fileParser) addAuxInterfacesFromFile(pkg string, file *ast.Fi...
    method parseFile (line 211) | func (p *fileParser) parseFile(importPath string, file *ast.File) (*mo...
    method parsePackage (line 248) | func (p *fileParser) parsePackage(path string) (*fileParser, error) {
    method parseInterface (line 277) | func (p *fileParser) parseInterface(name, pkg string, it *namedInterfa...
    method parseFunc (line 393) | func (p *fileParser) parseFunc(pkg string, f *ast.FuncType, tps map[st...
    method parseFieldList (line 420) | func (p *fileParser) parseFieldList(pkg string, fields []*ast.Field, t...
    method parseType (line 454) | func (p *fileParser) parseType(pkg string, typ ast.Expr, tps map[strin...
    method parseArrayLength (line 558) | func (p *fileParser) parseArrayLength(expr ast.Expr) (string, error) {
  function importsOfFile (line 600) | func importsOfFile(file *ast.File) (normalImports map[string]importedPac...
  type namedInterface (line 659) | type namedInterface struct
  function iterInterfaces (line 666) | func iterInterfaces(file *ast.File) <-chan *namedInterface {
  function isVariadic (line 693) | func isVariadic(f *ast.FuncType) bool {
  function packageNameOfDir (line 703) | func packageNameOfDir(srcDir string) (string, error) {

FILE: mockgen/parse_test.go
  function TestFileParser_ParseFile (line 9) | func TestFileParser_ParseFile(t *testing.T) {
  function TestFileParser_ParsePackage (line 40) | func TestFileParser_ParsePackage(t *testing.T) {
  function TestImportsOfFile (line 61) | func TestImportsOfFile(t *testing.T) {
  function checkGreeterImports (line 72) | func checkGreeterImports(t *testing.T, imports map[string]importedPackag...
  function Benchmark_parseFile (line 109) | func Benchmark_parseFile(b *testing.B) {
  function TestParseArrayWithConstLength (line 116) | func TestParseArrayWithConstLength(t *testing.T) {

FILE: mockgen/reflect.go
  function reflectMode (line 45) | func reflectMode(importPath string, symbols []string) (*model.Package, e...
  function writeProgram (line 81) | func writeProgram(importPath string, symbols []string) ([]byte, error) {
  function run (line 94) | func run(program string) (*model.Package, error) {
  function runInDir (line 134) | func runInDir(program []byte, dir string) (*model.Package, error) {
  type reflectData (line 182) | type reflectData struct

FILE: mockgen/version.go
  function printModuleVersion (line 23) | func printModuleVersion() {

FILE: sample/concurrent/concurrent.go
  type Math (line 6) | type Math interface

FILE: sample/concurrent/concurrent_test.go
  function call (line 13) | func call(ctx context.Context, m Math) (int, error) {
  function TestConcurrentFails (line 30) | func TestConcurrentFails(t *testing.T) {
  function TestConcurrentWorks (line 40) | func TestConcurrentWorks(t *testing.T) {

FILE: sample/concurrent/mock/concurrent_mock.go
  type MockMath (line 14) | type MockMath struct
    method EXPECT (line 32) | func (m *MockMath) EXPECT() *MockMathMockRecorder {
    method Sum (line 37) | func (m *MockMath) Sum(arg0, arg1 int) int {
  type MockMathMockRecorder (line 20) | type MockMathMockRecorder struct
    method Sum (line 45) | func (mr *MockMathMockRecorder) Sum(arg0, arg1 interface{}) *gomock.Ca...
  function NewMockMath (line 25) | func NewMockMath(ctrl *gomock.Controller) *MockMath {

FILE: sample/imp1/imp1.go
  type Imp1 (line 5) | type Imp1 struct
  type ImpT (line 7) | type ImpT
  type ForeignEmbedded (line 9) | type ForeignEmbedded interface

FILE: sample/imp2/imp2.go
  type Imp2 (line 3) | type Imp2 struct

FILE: sample/imp3/imp3.go
  type Imp3 (line 3) | type Imp3 struct

FILE: sample/imp4/imp4.go
  type Imp4 (line 3) | type Imp4 struct

FILE: sample/mock_user_test.go
  type MockIndex (line 25) | type MockIndex struct
    method EXPECT (line 43) | func (m *MockIndex) EXPECT() *MockIndexMockRecorder {
    method Anon (line 48) | func (m *MockIndex) Anon(arg0 string) {
    method Chan (line 60) | func (m *MockIndex) Chan(arg0 chan int, arg1 chan<- hash.Hash) {
    method ConcreteRet (line 72) | func (m *MockIndex) ConcreteRet() chan<- bool {
    method Ellip (line 86) | func (m *MockIndex) Ellip(arg0 string, arg1 ...interface{}) {
    method EllipOnly (line 103) | func (m *MockIndex) EllipOnly(arg0 ...string) {
    method ForeignFour (line 119) | func (m *MockIndex) ForeignFour(arg0 imp_four.Imp4) {
    method ForeignOne (line 131) | func (m *MockIndex) ForeignOne(arg0 imp1.Imp1) {
    method ForeignThree (line 143) | func (m *MockIndex) ForeignThree(arg0 imp3.Imp3) {
    method ForeignTwo (line 155) | func (m *MockIndex) ForeignTwo(arg0 imp2.Imp2) {
    method Func (line 167) | func (m *MockIndex) Func(arg0 func(http.Request) (int, bool)) {
    method Get (line 179) | func (m *MockIndex) Get(arg0 string) interface{} {
    method GetTwo (line 193) | func (m *MockIndex) GetTwo(arg0, arg1 string) (interface{}, interface{...
    method Map (line 208) | func (m *MockIndex) Map(arg0 map[int]hash.Hash) {
    method NillableRet (line 220) | func (m *MockIndex) NillableRet() error {
    method Other (line 234) | func (m *MockIndex) Other() hash.Hash {
    method Ptr (line 248) | func (m *MockIndex) Ptr(arg0 *int) {
    method Put (line 260) | func (m *MockIndex) Put(arg0 string, arg1 interface{}) {
    method Slice (line 272) | func (m *MockIndex) Slice(arg0 []int, arg1 []byte) [3]int {
    method Struct (line 286) | func (m *MockIndex) Struct(arg0 struct{}) {
    method StructChan (line 298) | func (m *MockIndex) StructChan(arg0 chan struct{}) {
    method Summary (line 310) | func (m *MockIndex) Summary(arg0 *bytes.Buffer, arg1 io.Writer) {
    method Templates (line 322) | func (m *MockIndex) Templates(arg0 template.CSS, arg1 template0.FuncMa...
  type MockIndexMockRecorder (line 31) | type MockIndexMockRecorder struct
    method Anon (line 54) | func (mr *MockIndexMockRecorder) Anon(arg0 interface{}) *gomock.Call {
    method Chan (line 66) | func (mr *MockIndexMockRecorder) Chan(arg0, arg1 interface{}) *gomock....
    method ConcreteRet (line 80) | func (mr *MockIndexMockRecorder) ConcreteRet() *gomock.Call {
    method Ellip (line 96) | func (mr *MockIndexMockRecorder) Ellip(arg0 interface{}, arg1 ...inter...
    method EllipOnly (line 113) | func (mr *MockIndexMockRecorder) EllipOnly(arg0 ...interface{}) *gomoc...
    method ForeignFour (line 125) | func (mr *MockIndexMockRecorder) ForeignFour(arg0 interface{}) *gomock...
    method ForeignOne (line 137) | func (mr *MockIndexMockRecorder) ForeignOne(arg0 interface{}) *gomock....
    method ForeignThree (line 149) | func (mr *MockIndexMockRecorder) ForeignThree(arg0 interface{}) *gomoc...
    method ForeignTwo (line 161) | func (mr *MockIndexMockRecorder) ForeignTwo(arg0 interface{}) *gomock....
    method Func (line 173) | func (mr *MockIndexMockRecorder) Func(arg0 interface{}) *gomock.Call {
    method Get (line 187) | func (mr *MockIndexMockRecorder) Get(arg0 interface{}) *gomock.Call {
    method GetTwo (line 202) | func (mr *MockIndexMockRecorder) GetTwo(arg0, arg1 interface{}) *gomoc...
    method Map (line 214) | func (mr *MockIndexMockRecorder) Map(arg0 interface{}) *gomock.Call {
    method NillableRet (line 228) | func (mr *MockIndexMockRecorder) NillableRet() *gomock.Call {
    method Other (line 242) | func (mr *MockIndexMockRecorder) Other() *gomock.Call {
    method Ptr (line 254) | func (mr *MockIndexMockRecorder) Ptr(arg0 interface{}) *gomock.Call {
    method Put (line 266) | func (mr *MockIndexMockRecorder) Put(arg0, arg1 interface{}) *gomock.C...
    method Slice (line 280) | func (mr *MockIndexMockRecorder) Slice(arg0, arg1 interface{}) *gomock...
    method Struct (line 292) | func (mr *MockIndexMockRecorder) Struct(arg0 interface{}) *gomock.Call {
    method StructChan (line 304) | func (mr *MockIndexMockRecorder) StructChan(arg0 interface{}) *gomock....
    method Summary (line 316) | func (mr *MockIndexMockRecorder) Summary(arg0, arg1 interface{}) *gomo...
    method Templates (line 328) | func (mr *MockIndexMockRecorder) Templates(arg0, arg1 interface{}) *go...
  function NewMockIndex (line 36) | func NewMockIndex(ctrl *gomock.Controller) *MockIndex {
  type MockEmbed (line 334) | type MockEmbed struct
    method EXPECT (line 352) | func (m *MockEmbed) EXPECT() *MockEmbedMockRecorder {
    method EmbeddedMethod (line 357) | func (m *MockEmbed) EmbeddedMethod() {
    method ForeignEmbeddedMethod (line 369) | func (m *MockEmbed) ForeignEmbeddedMethod() *bufio.Reader {
    method ImplicitPackage (line 383) | func (m *MockEmbed) ImplicitPackage(arg0 string, arg1 imp1.ImpT, arg2 ...
    method RegularMethod (line 395) | func (m *MockEmbed) RegularMethod() {
  type MockEmbedMockRecorder (line 340) | type MockEmbedMockRecorder struct
    method EmbeddedMethod (line 363) | func (mr *MockEmbedMockRecorder) EmbeddedMethod() *gomock.Call {
    method ForeignEmbeddedMethod (line 377) | func (mr *MockEmbedMockRecorder) ForeignEmbeddedMethod() *gomock.Call {
    method ImplicitPackage (line 389) | func (mr *MockEmbedMockRecorder) ImplicitPackage(arg0, arg1, arg2, arg...
    method RegularMethod (line 401) | func (mr *MockEmbedMockRecorder) RegularMethod() *gomock.Call {
  function NewMockEmbed (line 345) | func NewMockEmbed(ctrl *gomock.Controller) *MockEmbed {
  type MockEmbedded (line 407) | type MockEmbedded struct
    method EXPECT (line 425) | func (m *MockEmbedded) EXPECT() *MockEmbeddedMockRecorder {
    method EmbeddedMethod (line 430) | func (m *MockEmbedded) EmbeddedMethod() {
  type MockEmbeddedMockRecorder (line 413) | type MockEmbeddedMockRecorder struct
    method EmbeddedMethod (line 436) | func (mr *MockEmbeddedMockRecorder) EmbeddedMethod() *gomock.Call {
  function NewMockEmbedded (line 418) | func NewMockEmbedded(ctrl *gomock.Controller) *MockEmbedded {

FILE: sample/user.go
  type Index (line 37) | type Index interface
  type Embed (line 86) | type Embed interface
  type Embedded (line 92) | type Embedded interface
  function Remember (line 101) | func Remember(index Index, keys []string, values []interface{}) {
  function GrabPointer (line 116) | func GrabPointer(index Index) int {

FILE: sample/user_test.go
  function TestRemember (line 12) | func TestRemember(t *testing.T) {
  function TestVariadicFunction (line 65) | func TestVariadicFunction(t *testing.T) {
  function TestGrabPointer (line 123) | func TestGrabPointer(t *testing.T) {
  function TestEmbeddedInterface (line 136) | func TestEmbeddedInterface(t *testing.T) {
  function TestExpectTrueNil (line 151) | func TestExpectTrueNil(t *testing.T) {
  function TestDoAndReturnSignature (line 162) | func TestDoAndReturnSignature(t *testing.T) {
Condensed preview — 135 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (354K chars).
[
  {
    "path": ".github/CODEOWNERS",
    "chars": 29,
    "preview": "*                   @codyoss\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.md",
    "chars": 567,
    "preview": "---\nname: Bug report\nabout: Report a bug in gomock\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n**Actual behavior** A clear "
  },
  {
    "path": ".github/ISSUE_TEMPLATE/config.yml",
    "chars": 295,
    "preview": "blank_issues_enabled: true\n#contact_links:\n#  - name: GitHub Community Forum\n#    url: https://github.community/\n#    ab"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.md",
    "chars": 459,
    "preview": "---\nname: Feature request\nabout: Propose a new feature for gomock\ntitle: ''\nlabels: 'type: feature request'\nassignees: '"
  },
  {
    "path": ".github/workflows/test.yaml",
    "chars": 1065,
    "preview": "name: Run tests\non:\n  push:\n    branches: [main]\n  pull_request:\n    branches: [main]\nenv:\n  GO111MODULE: on\njobs:\n  tes"
  },
  {
    "path": ".gitignore",
    "chars": 244,
    "preview": "# Object files and binaries from go.\n*.[568]\n\n# Library files.\n*.a\n\n# Any file prefixed by an underscore.\n*/_*\n\n# System"
  },
  {
    "path": ".goreleaser.yml",
    "chars": 770,
    "preview": "# Release automation via GoReleaser (goreleaser.com)\n# Requires a valid GITHUB_TOKEN envar prior to running `goreleaser`"
  },
  {
    "path": "AUTHORS",
    "chars": 371,
    "preview": "# This is the official list of GoMock authors for copyright purposes.\n# This file is distinct from the CONTRIBUTORS file"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 627,
    "preview": "# Contributing\n\nFirst off, thank you for taking an interest to contribute to this project!\n\n## Opening issues\n\nWhen open"
  },
  {
    "path": "CONTRIBUTORS",
    "chars": 1495,
    "preview": "# This is the official list of people who can contribute (and typically\n# have contributed) code to the gomock repositor"
  },
  {
    "path": "LICENSE",
    "chars": 11358,
    "preview": "\n                                 Apache License\n                           Version 2.0, January 2004\n                  "
  },
  {
    "path": "README.md",
    "chars": 8153,
    "preview": "# gomock\n\n**Update, June 2023**: _This repo and tool are no longer maintained.\nPlease see [go.uber.org/mock](https://git"
  },
  {
    "path": "ci/check_panic_handling.sh",
    "chars": 905,
    "preview": "#!/bin/bash\n# Copyright 2010 Google LLC.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may n"
  },
  {
    "path": "ci/test.sh",
    "chars": 768,
    "preview": "#!/bin/bash\n# This script is used to ensure that the go.mod file is up to date.\n\nset -euo pipefail\n\nif [[ $(go version) "
  },
  {
    "path": "go.mod",
    "chars": 104,
    "preview": "module github.com/golang/mock\n\nrequire (\n\tgolang.org/x/mod v0.5.1\n\tgolang.org/x/tools v0.1.8\n)\n\ngo 1.15\n"
  },
  {
    "path": "go.sum",
    "chars": 2868,
    "preview": "github.com/yuin/goldmark v1.4.1 h1:/vn0k+RBvwlxEmP5E7SZMqNxPhfMVFEJiykr15/0XKM=\ngithub.com/yuin/goldmark v1.4.1/go.mod h"
  },
  {
    "path": "gomock/call.go",
    "chars": 15527,
    "preview": "// Copyright 2010 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "gomock/call_test.go",
    "chars": 15594,
    "preview": "// Copyright 2020 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "gomock/callset.go",
    "chars": 3104,
    "preview": "// Copyright 2011 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "gomock/callset_test.go",
    "chars": 2628,
    "preview": "// Copyright 2011 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "gomock/controller.go",
    "chars": 8652,
    "preview": "// Copyright 2010 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "gomock/controller_test.go",
    "chars": 26592,
    "preview": "// Copyright 2011 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "gomock/doc.go",
    "chars": 2537,
    "preview": "// Copyright 2022 Google LLC\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use th"
  },
  {
    "path": "gomock/example_test.go",
    "chars": 986,
    "preview": "package gomock_test\n\n//go:generate mockgen -destination mock_test.go -package gomock_test -source example_test.go\n\nimpor"
  },
  {
    "path": "gomock/internal/mock_gomock/mock_matcher.go",
    "chars": 1746,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: github.com/golang/mock/gomock (interfaces: Matcher)\n\n// Package mo"
  },
  {
    "path": "gomock/matchers.go",
    "chars": 8334,
    "preview": "// Copyright 2010 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "gomock/matchers_test.go",
    "chars": 8694,
    "preview": "// Copyright 2010 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "gomock/mock_test.go",
    "chars": 1189,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: example_test.go\n\n// Package gomock_test is a generated GoMock pack"
  },
  {
    "path": "mockgen/generic_go118.go",
    "chars": 1884,
    "preview": "// Copyright 2022 Google LLC\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use th"
  },
  {
    "path": "mockgen/generic_notgo118.go",
    "chars": 969,
    "preview": "// Copyright 2022 Google LLC\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use th"
  },
  {
    "path": "mockgen/internal/tests/aux_imports_embedded_interface/README.md",
    "chars": 974,
    "preview": "# Embedded Interfaces in aux_files\n\nEmbedded interfaces in `aux_files` generate `unknown embedded interface XXX` errors."
  },
  {
    "path": "mockgen/internal/tests/aux_imports_embedded_interface/bugreport.go",
    "chars": 417,
    "preview": "package bugreport\n\n//go:generate mockgen -aux_files faux=faux/faux.go -destination bugreport_mock.go -package bugreport "
  },
  {
    "path": "mockgen/internal/tests/aux_imports_embedded_interface/bugreport_mock.go",
    "chars": 1726,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: bugreport.go\n\n// Package bugreport is a generated GoMock package.\n"
  },
  {
    "path": "mockgen/internal/tests/aux_imports_embedded_interface/bugreport_test.go",
    "chars": 328,
    "preview": "package bugreport\n\nimport (\n\t\"testing\"\n\n\t\"github.com/golang/mock/gomock\"\n)\n\n// TestValidInterface assesses whether or no"
  },
  {
    "path": "mockgen/internal/tests/aux_imports_embedded_interface/faux/faux.go",
    "chars": 127,
    "preview": "package faux\n\ntype Foreign interface {\n\tMethod() Return\n\tEmbedded\n\terror\n}\n\ntype Embedded interface{}\n\ntype Return inter"
  },
  {
    "path": "mockgen/internal/tests/const_array_length/input.go",
    "chars": 279,
    "preview": "package const_length\n\nimport \"math\"\n\n//go:generate mockgen -package const_length -destination mock.go -source input.go\n\n"
  },
  {
    "path": "mockgen/internal/tests/const_array_length/mock.go",
    "chars": 2979,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: input.go\n\n// Package const_length is a generated GoMock package.\np"
  },
  {
    "path": "mockgen/internal/tests/copyright_file/input.go",
    "chars": 172,
    "preview": "package empty_interface\n\n//go:generate mockgen -package empty_interface -destination mock.go -source input.go -copyright"
  },
  {
    "path": "mockgen/internal/tests/copyright_file/mock.go",
    "chars": 1024,
    "preview": "// This is a mock copyright header.\n//\n// Lorem ipsum dolor sit amet, consectetur adipiscing elit,\n// sed do eiusmod tem"
  },
  {
    "path": "mockgen/internal/tests/copyright_file/mock_copyright_header",
    "chars": 212,
    "preview": "This is a mock copyright header.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit,\nsed do eiusmod tempor incidid"
  },
  {
    "path": "mockgen/internal/tests/custom_package_name/README.md",
    "chars": 999,
    "preview": "# Tests for custom package names\n\nThis directory contains test for mockgen generating mocks when imported package\nname d"
  },
  {
    "path": "mockgen/internal/tests/custom_package_name/client/v1/client.go",
    "chars": 185,
    "preview": "package client\n\nimport \"fmt\"\n\ntype Client struct{}\n\nfunc (c *Client) Greet(in GreetInput) string {\n\treturn fmt.Sprintf(\""
  },
  {
    "path": "mockgen/internal/tests/custom_package_name/greeter/greeter.go",
    "chars": 757,
    "preview": "package greeter\n\n//go:generate mockgen -source greeter.go -destination greeter_mock_test.go -package greeter\n\nimport (\n\t"
  },
  {
    "path": "mockgen/internal/tests/custom_package_name/greeter/greeter_mock_test.go",
    "chars": 1426,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: greeter.go\n\n// Package greeter is a generated GoMock package.\npack"
  },
  {
    "path": "mockgen/internal/tests/custom_package_name/greeter/greeter_test.go",
    "chars": 686,
    "preview": "package greeter\n\nimport (\n\t\"testing\"\n\n\t\"github.com/golang/mock/gomock\"\n\t\"github.com/golang/mock/mockgen/internal/tests/c"
  },
  {
    "path": "mockgen/internal/tests/custom_package_name/validator/validate.go",
    "chars": 65,
    "preview": "package validator\n\nfunc Validate(s string) error {\n\treturn nil\n}\n"
  },
  {
    "path": "mockgen/internal/tests/dot_imports/input.go",
    "chars": 248,
    "preview": "package dot_imports\n\n//go:generate mockgen -package dot_imports -destination mock.go -source input.go\n\nimport (\n\t\"bytes\""
  },
  {
    "path": "mockgen/internal/tests/dot_imports/mock.go",
    "chars": 2316,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: input.go\n\n// Package dot_imports is a generated GoMock package.\npa"
  },
  {
    "path": "mockgen/internal/tests/empty_interface/input.go",
    "chars": 134,
    "preview": "package empty_interface\n\n//go:generate mockgen -package empty_interface -destination mock.go -source input.go\n\ntype Empt"
  },
  {
    "path": "mockgen/internal/tests/empty_interface/mock.go",
    "chars": 795,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: input.go\n\n// Package empty_interface is a generated GoMock package"
  },
  {
    "path": "mockgen/internal/tests/extra_import/import.go",
    "chars": 275,
    "preview": "// Package extra_import makes sure output does not import it. See #515.\npackage extra_import\n\n//go:generate mockgen -des"
  },
  {
    "path": "mockgen/internal/tests/extra_import/mock.go",
    "chars": 1245,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: github.com/golang/mock/mockgen/internal/tests/extra_import (interf"
  },
  {
    "path": "mockgen/internal/tests/generated_identifier_conflict/README.md",
    "chars": 823,
    "preview": "# Generated Identifier Conflict\n\nThe generated mock methods use some hardcoded variable/receiver names that can\nhave con"
  },
  {
    "path": "mockgen/internal/tests/generated_identifier_conflict/bugreport.go",
    "chars": 667,
    "preview": "package bugreport\n\n//go:generate mockgen -destination bugreport_mock.go -package bugreport -source=bugreport.go\n\ntype Ex"
  },
  {
    "path": "mockgen/internal/tests/generated_identifier_conflict/bugreport_mock.go",
    "chars": 1976,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: bugreport.go\n\n// Package bugreport is a generated GoMock package.\n"
  },
  {
    "path": "mockgen/internal/tests/generated_identifier_conflict/bugreport_test.go",
    "chars": 450,
    "preview": "package bugreport\n\nimport (\n\t\"github.com/golang/mock/gomock\"\n\t\"testing\"\n)\n\nfunc TestExample_Method(t *testing.T) {\n\tctrl"
  },
  {
    "path": "mockgen/internal/tests/generics/external.go",
    "chars": 484,
    "preview": "package generics\n\nimport (\n\t\"github.com/golang/mock/mockgen/internal/tests/generics/other\"\n\t\"golang.org/x/exp/constraint"
  },
  {
    "path": "mockgen/internal/tests/generics/generics.go",
    "chars": 1012,
    "preview": "package generics\n\nimport \"github.com/golang/mock/mockgen/internal/tests/generics/other\"\n\n//go:generate mockgen --source="
  },
  {
    "path": "mockgen/internal/tests/generics/go.mod",
    "chars": 215,
    "preview": "module github.com/golang/mock/mockgen/internal/tests/generics\n\ngo 1.18\n\nrequire (\n\tgithub.com/golang/mock v1.6.0\n\tgolang"
  },
  {
    "path": "mockgen/internal/tests/generics/go.sum",
    "chars": 2645,
    "preview": "github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=\ngolang.org/x/crypto v0.0.0-201903"
  },
  {
    "path": "mockgen/internal/tests/generics/other/other.go",
    "chars": 137,
    "preview": "package other\n\ntype One[T any] struct{}\n\ntype Two[T any, R any] struct{}\n\ntype Three struct{}\n\ntype Four struct{}\n\ntype "
  },
  {
    "path": "mockgen/internal/tests/generics/source/mock_external_test.go",
    "chars": 6116,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: external.go\n\n// Package source is a generated GoMock package.\npack"
  },
  {
    "path": "mockgen/internal/tests/generics/source/mock_generics_test.go",
    "chars": 10535,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: generics.go\n\n// Package source is a generated GoMock package.\npack"
  },
  {
    "path": "mockgen/internal/tests/import_embedded_interface/bugreport.go",
    "chars": 1105,
    "preview": "// Copyright 2020 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "mockgen/internal/tests/import_embedded_interface/bugreport_mock.go",
    "chars": 2663,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: bugreport.go\n\n// Package bugreport is a generated GoMock package.\n"
  },
  {
    "path": "mockgen/internal/tests/import_embedded_interface/bugreport_test.go",
    "chars": 952,
    "preview": "// Copyright 2020 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "mockgen/internal/tests/import_embedded_interface/ersatz/ersatz.go",
    "chars": 674,
    "preview": "// Copyright 2020 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "mockgen/internal/tests/import_embedded_interface/faux/conflict.go",
    "chars": 726,
    "preview": "// Copyright 2020 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "mockgen/internal/tests/import_embedded_interface/faux/faux.go",
    "chars": 791,
    "preview": "// Copyright 2020 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "mockgen/internal/tests/import_embedded_interface/foo.go",
    "chars": 74,
    "preview": "package bugreport\n\ntype Foo interface {\n\tBar() Baz\n}\ntype Baz interface{}\n"
  },
  {
    "path": "mockgen/internal/tests/import_embedded_interface/net.go",
    "chars": 785,
    "preview": "//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance "
  },
  {
    "path": "mockgen/internal/tests/import_embedded_interface/net_mock.go",
    "chars": 2101,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: net.go\n\n// Package bugreport is a generated GoMock package.\npackag"
  },
  {
    "path": "mockgen/internal/tests/import_embedded_interface/net_test.go",
    "chars": 919,
    "preview": "// Copyright 2020 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "mockgen/internal/tests/import_embedded_interface/other/ersatz/ersatz.go",
    "chars": 679,
    "preview": "// Copyright 2020 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "mockgen/internal/tests/import_embedded_interface/other/log/log.go",
    "chars": 615,
    "preview": "// Copyright 2020 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "mockgen/internal/tests/import_source/README.md",
    "chars": 225,
    "preview": "# Import Source\n\nTest the case where the generated code uses a type defined in the source package (in source mode). Ther"
  },
  {
    "path": "mockgen/internal/tests/import_source/definition/source.go",
    "chars": 216,
    "preview": "package source\n\n//go:generate mockgen -destination ../source_mock.go -source=source.go\n//go:generate mockgen -package so"
  },
  {
    "path": "mockgen/internal/tests/import_source/definition/source_mock.go",
    "chars": 1068,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: source.go\n\n// Package source is a generated GoMock package.\npackag"
  },
  {
    "path": "mockgen/internal/tests/import_source/source_mock.go",
    "chars": 1166,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: source.go\n\n// Package mock_source is a generated GoMock package.\np"
  },
  {
    "path": "mockgen/internal/tests/internal_pkg/generate.go",
    "chars": 290,
    "preview": "package test\n\n//go:generate mockgen -destination subdir/internal/pkg/reflect_output/mock.go github.com/golang/mock/mockg"
  },
  {
    "path": "mockgen/internal/tests/internal_pkg/subdir/internal/pkg/input.go",
    "chars": 81,
    "preview": "package pkg\n\ntype Arg interface {\n\tFoo() int\n}\n\ntype Intf interface {\n\tF() Arg\n}\n"
  },
  {
    "path": "mockgen/internal/tests/internal_pkg/subdir/internal/pkg/reflect_output/mock.go",
    "chars": 1323,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: github.com/golang/mock/mockgen/internal/tests/internal_pkg/subdir/"
  },
  {
    "path": "mockgen/internal/tests/internal_pkg/subdir/internal/pkg/source_output/mock.go",
    "chars": 2188,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: subdir/internal/pkg/input.go\n\n// Package mock_pkg is a generated G"
  },
  {
    "path": "mockgen/internal/tests/missing_import/output/source_mock.go",
    "chars": 1207,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: source.go\n\n// Package source is a generated GoMock package.\npackag"
  },
  {
    "path": "mockgen/internal/tests/missing_import/source/source.go",
    "chars": 222,
    "preview": "// Package source makes sure output imports its. See #505.\npackage source\n\n//go:generate mockgen -package source -destin"
  },
  {
    "path": "mockgen/internal/tests/mock_in_test_package/README.md",
    "chars": 594,
    "preview": "# Mock in Test Package\n\nTest the case where the package has the `_test` suffix.\n\nPrior to patch:\n\n```bash\n$ go generate\n"
  },
  {
    "path": "mockgen/internal/tests/mock_in_test_package/mock_test.go",
    "chars": 1722,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: user.go\n\n// Package users_test is a generated GoMock package.\npack"
  },
  {
    "path": "mockgen/internal/tests/mock_in_test_package/user.go",
    "chars": 205,
    "preview": "package users\n\n//go:generate mockgen --source=user.go --destination=mock_test.go --package=users_test\n\ntype User struct "
  },
  {
    "path": "mockgen/internal/tests/overlapping_methods/interfaces.go",
    "chars": 164,
    "preview": "package overlap\n\ntype ReadCloser interface {\n\tRead([]byte) (int, error)\n\tClose() error\n}\n\ntype WriteCloser interface {\n\t"
  },
  {
    "path": "mockgen/internal/tests/overlapping_methods/mock.go",
    "chars": 2366,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: overlap.go\n\n// Package overlap is a generated GoMock package.\npack"
  },
  {
    "path": "mockgen/internal/tests/overlapping_methods/overlap.go",
    "chars": 248,
    "preview": "package overlap\n\n//go:generate mockgen -package overlap -destination mock.go -source overlap.go -aux_files github.com/go"
  },
  {
    "path": "mockgen/internal/tests/overlapping_methods/overlap_test.go",
    "chars": 356,
    "preview": "package overlap\n\nimport (\n\t\"errors\"\n\t\"testing\"\n\n\tgomock \"github.com/golang/mock/gomock\"\n)\n\n// TestValidInterface assesse"
  },
  {
    "path": "mockgen/internal/tests/panicing_test/mock_test.go",
    "chars": 1519,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: panic.go\n\n// Package paniccode is a generated GoMock package.\npack"
  },
  {
    "path": "mockgen/internal/tests/panicing_test/panic.go",
    "chars": 830,
    "preview": "// Copyright 2020 Google LLC\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use th"
  },
  {
    "path": "mockgen/internal/tests/panicing_test/panic_test.go",
    "chars": 1114,
    "preview": "//go:build panictest\n// +build panictest\n\n// Copyright 2020 Google LLC\n//\n// Licensed under the Apache License, Version "
  },
  {
    "path": "mockgen/internal/tests/parenthesized_parameter_type/README.md",
    "chars": 97,
    "preview": "# Parenthesized Parameter Type\n\nTest for [Issue#416](https://github.com/golang/mock/issues/416).\n"
  },
  {
    "path": "mockgen/internal/tests/parenthesized_parameter_type/input.go",
    "chars": 107,
    "preview": "package parenthesized_parameter_type\n\ntype Example interface {\n\tParenthesizedParameterType(param *(int))\n}\n"
  },
  {
    "path": "mockgen/internal/tests/parenthesized_parameter_type/mock.go",
    "chars": 1479,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: ./mockgen/internal/tests/parenthesized_parameter_type/input.go\n\n//"
  },
  {
    "path": "mockgen/internal/tests/performance/big_interface/big_interface.go",
    "chars": 3605,
    "preview": "package big_interface\n\ntype Bar struct{}\n\ntype BigInterface interface {\n\tFoo1(bool, bool, bool, bool, bool, bool, bool, "
  },
  {
    "path": "mockgen/internal/tests/self_package/mock.go",
    "chars": 1308,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: github.com/golang/mock/mockgen/internal/tests/self_package (interf"
  },
  {
    "path": "mockgen/internal/tests/self_package/types.go",
    "chars": 275,
    "preview": "package core\n\n//go:generate mockgen -package core -self_package github.com/golang/mock/mockgen/internal/tests/self_packa"
  },
  {
    "path": "mockgen/internal/tests/test_package/foo.go",
    "chars": 14,
    "preview": "package users\n"
  },
  {
    "path": "mockgen/internal/tests/test_package/mock_test.go",
    "chars": 1633,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: user_test.go\n\n// Package users_test is a generated GoMock package."
  },
  {
    "path": "mockgen/internal/tests/test_package/user_test.go",
    "chars": 215,
    "preview": "package users_test\n\n//go:generate mockgen --source=user_test.go --destination=mock_test.go --package=users_test\n\ntype Us"
  },
  {
    "path": "mockgen/internal/tests/unexported_method/README.md",
    "chars": 88,
    "preview": "# Unexported Method\n\nFrom #52, this tests an unexported method in the mocked interface.\n"
  },
  {
    "path": "mockgen/internal/tests/unexported_method/bugreport.go",
    "chars": 371,
    "preview": "package bugreport\n\n//go:generate mockgen -destination bugreport_mock.go -package bugreport -source=bugreport.go Example\n"
  },
  {
    "path": "mockgen/internal/tests/unexported_method/bugreport_mock.go",
    "chars": 1317,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: bugreport.go\n\n// Package bugreport is a generated GoMock package.\n"
  },
  {
    "path": "mockgen/internal/tests/unexported_method/bugreport_test.go",
    "chars": 271,
    "preview": "package bugreport\n\nimport (\n\t\"testing\"\n\n\t\"github.com/golang/mock/gomock\"\n)\n\nfunc TestCallExample(t *testing.T) {\n\tctrl :"
  },
  {
    "path": "mockgen/internal/tests/vendor_dep/README.md",
    "chars": 145,
    "preview": "# Vendor Dep\n\nTest for [Issue#4](https://github.com/golang/mock/issues/4).\nAlso see discussion on [#28](https://github.c"
  },
  {
    "path": "mockgen/internal/tests/vendor_dep/doc.go",
    "chars": 236,
    "preview": "package vendor_dep\n\n//go:generate mockgen -package vendor_dep -destination mock.go github.com/golang/mock/mockgen/intern"
  },
  {
    "path": "mockgen/internal/tests/vendor_dep/mock.go",
    "chars": 1397,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: github.com/golang/mock/mockgen/internal/tests/vendor_dep (interfac"
  },
  {
    "path": "mockgen/internal/tests/vendor_dep/source_mock_package/mock.go",
    "chars": 1339,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: vendor_dep.go\n\n// Package mock_vendor_dep is a generated GoMock pa"
  },
  {
    "path": "mockgen/internal/tests/vendor_dep/vendor_dep.go",
    "chars": 107,
    "preview": "package vendor_dep\n\nimport \"golang.org/x/tools/present\"\n\ntype VendorsDep interface {\n\tFoo() present.Elem\n}\n"
  },
  {
    "path": "mockgen/internal/tests/vendor_pkg/README.md",
    "chars": 75,
    "preview": "# Vendor Pkg\n\nTest for [Issue#4](https://github.com/golang/mock/issues/4).\n"
  },
  {
    "path": "mockgen/internal/tests/vendor_pkg/doc.go",
    "chars": 115,
    "preview": "package vendor_pkg\n\n//go:generate mockgen -destination mock.go -package vendor_pkg golang.org/x/tools/present Elem\n"
  },
  {
    "path": "mockgen/internal/tests/vendor_pkg/mock.go",
    "chars": 1275,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: golang.org/x/tools/present (interfaces: Elem)\n\n// Package vendor_p"
  },
  {
    "path": "mockgen/mockgen.go",
    "chars": 21272,
    "preview": "// Copyright 2010 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "mockgen/mockgen_test.go",
    "chars": 11433,
    "preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"reflect\"\n\t\"regexp\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.c"
  },
  {
    "path": "mockgen/model/model.go",
    "chars": 12801,
    "preview": "// Copyright 2012 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "mockgen/model/model_test.go",
    "chars": 800,
    "preview": "package model\n\nimport (\n\t\"fmt\"\n\t\"testing\"\n)\n\nfunc TestImpPath(t *testing.T) {\n\tnonVendor := \"github.com/foo/bar\"\n\tif non"
  },
  {
    "path": "mockgen/parse.go",
    "chars": 20071,
    "preview": "// Copyright 2012 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "mockgen/parse_test.go",
    "chars": 4234,
    "preview": "package main\n\nimport (\n\t\"go/parser\"\n\t\"go/token\"\n\t\"testing\"\n)\n\nfunc TestFileParser_ParseFile(t *testing.T) {\n\tfs := token"
  },
  {
    "path": "mockgen/reflect.go",
    "chars": 6438,
    "preview": "// Copyright 2012 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use t"
  },
  {
    "path": "mockgen/version.go",
    "chars": 933,
    "preview": "// Copyright 2022 Google LLC\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use th"
  },
  {
    "path": "sample/README.md",
    "chars": 705,
    "preview": "# Samples\n\nThis directory contains an example of a package containing a non-trivial\ninterface that can be mocked with Go"
  },
  {
    "path": "sample/concurrent/concurrent.go",
    "chars": 239,
    "preview": "// Package concurrent demonstrates how to use gomock with goroutines.\npackage concurrent\n\n//go:generate mockgen -destina"
  },
  {
    "path": "sample/concurrent/concurrent_test.go",
    "chars": 1103,
    "preview": "package concurrent\n\nimport (\n\t\"testing\"\n\n\t\"context\"\n\n\t\"github.com/golang/mock/gomock\"\n\n\tmock \"github.com/golang/mock/sam"
  },
  {
    "path": "sample/concurrent/mock/concurrent_mock.go",
    "chars": 1281,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: github.com/golang/mock/sample/concurrent (interfaces: Math)\n\n// Pa"
  },
  {
    "path": "sample/imp1/imp1.go",
    "chars": 417,
    "preview": "package imp1\n\nimport \"bufio\"\n\ntype Imp1 struct{}\n\ntype ImpT int\n\ntype ForeignEmbedded interface {\n\t// The return value h"
  },
  {
    "path": "sample/imp2/imp2.go",
    "chars": 33,
    "preview": "package imp2\n\ntype Imp2 struct{}\n"
  },
  {
    "path": "sample/imp3/imp3.go",
    "chars": 33,
    "preview": "package imp3\n\ntype Imp3 struct{}\n"
  },
  {
    "path": "sample/imp4/imp4.go",
    "chars": 37,
    "preview": "package imp_four\n\ntype Imp4 struct{}\n"
  },
  {
    "path": "sample/mock_user_test.go",
    "chars": 14318,
    "preview": "// Code generated by MockGen. DO NOT EDIT.\n// Source: github.com/golang/mock/sample (interfaces: Index,Embed,Embedded)\n\n"
  },
  {
    "path": "sample/user.go",
    "chars": 2864,
    "preview": "// Package user is an example package with an interface.\npackage user\n\n//go:generate mockgen -destination mock_user_test"
  },
  {
    "path": "sample/user_test.go",
    "chars": 5250,
    "preview": "// A test that uses a mock.\npackage user_test\n\nimport (\n\t\"testing\"\n\n\t\"github.com/golang/mock/gomock\"\n\tuser \"github.com/g"
  }
]

About this extraction

This page contains the full source code of the golang/mock GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 135 files (312.4 KB), approximately 92.6k tokens, and a symbol index with 775 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!