This repository has been archived by the owner on Jun 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add notes and error helper for vendor+reflect error (#567)
- Loading branch information
Showing
2 changed files
with
30 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,17 +30,6 @@ go install github.com/golang/mock/[email protected] | |
If you use `mockgen` in your CI pipeline, it may be more appropriate to fixate | ||
on a specific mockgen version. | ||
|
||
## Documentation | ||
|
||
After installing, you can use `go doc` to get documentation: | ||
|
||
```bash | ||
go doc github.com/golang/mock/gomock | ||
``` | ||
|
||
Alternatively, there is an online reference for the package hosted on GoPkgDoc | ||
[here][gomock-reference]. | ||
|
||
## Running mockgen | ||
|
||
`mockgen` has two modes of operation: source and reflect. | ||
|
@@ -265,3 +254,23 @@ If the received value is `3`, then it will be printed as `03`. | |
[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 do 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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters