| 1 |
# Generated Identifier Conflict |
| 2 |
|
| 3 |
The generated mock methods use some hardcoded variable/receiver names that can |
| 4 |
have conflicts with the argument names that are defined by the code for which |
| 5 |
the mock is generated when using the source generation method. |
| 6 |
|
| 7 |
Example: |
| 8 |
|
| 9 |
```go |
| 10 |
type Example interface { |
| 11 |
Method(_m, _mr, m, mr int) |
| 12 |
} |
| 13 |
``` |
| 14 |
|
| 15 |
```go |
| 16 |
// Method mocks base method |
| 17 |
func (_m *MockExample) Method(_m int, _mr int, m int, mr int) { |
| 18 |
_m.ctrl.Call(_m, "Method", _m, _mr, m, mr) |
| 19 |
} |
| 20 |
``` |
| 21 |
|
| 22 |
In the above example one of the interface method parameters is called `_m` |
| 23 |
but unfortunately the generated receiver name is also called `_m` so the |
| 24 |
mock code won't compile. |
| 25 |
|
| 26 |
The generator has to make sure that generated identifiers (e.g.: the receiver |
| 27 |
names) are always different from the arg names that might come from external |
| 28 |
sources. |