Commit 768f9ed
committed
Avoid stringer-related deadlocks without adding ISGOMOCK
A deadlock related to controller calling Stringer on mocks themselves
was revealed in uber-go#116. uber-go#114 solved this deadlock by adding a generated
`ISGOMOCK()` method to all generated mocks, and then checking for it
before calling `.String()` on arguments.
This reveals an exported method on each generated mock that:
* Bloats the generated code
* Can be taken dependency on in strange ways via Hyrum's Law
* Technically opens up another route for naming collision.
This PR attempts to clean up this type of check by instead generating
an unexported field in generated mock structs instead, and checks for it using reflect.
This hides this implementation detail of gomock/mockgen better,
and produces less generated bloat.
Ref: uber-go#1161 parent 60372e3 commit 768f9ed
File tree
36 files changed
+129
-189
lines changed- gomock
- internal/mock_gomock
- internal/mock_gomock
- mockgen
- internal/tests
- add_generate_directive
- const_array_length
- copyright_file
- custom_package_name/greeter
- defined_import_local_name
- dot_imports
- empty_interface
- exclude
- extra_import
- generated_identifier_conflict
- import_embedded_interface
- import_source
- definition
- internal_pkg/subdir/internal/pkg/source_output
- missing_import/output
- mock_in_test_package
- mock_name/mocks
- overlapping_methods
- package_comment
- panicing_test
- sanitization/mockout
- self_package
- test_package
- typed_inorder
- unexported_method
- vendor_dep
- source_mock_package
- vendor_pkg
36 files changed
+129
-189
lines changedLines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
12 | 7 | | |
13 | 8 | | |
14 | 9 | | |
15 | 10 | | |
16 | 11 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
24 | 33 | | |
| 34 | + | |
| 35 | + | |
25 | 36 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments