File: README.md

package info (click to toggle)
golang-go.uber-mock 0.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,176 kB
  • sloc: sh: 37; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 823 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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.