In many projects, I have a tools/tools.go file that allows me to have local versions of the tools I use (reference).
I also have go:generate statements in my code to automate the generation of mock files using https://github.com/golang/mock/mockgen. I have a local version of mockgen under a bin folder of my project and I can generate all the mocks of my project by running something like PATH=./bin:${PATH} go generate ./....
Vscode-go recognizes the go:generate statements in the code and can generate code for us.
I would like to know if there is a way to get vscode-go to run mockgen (through gopls.generate) using the local version I have under the bin directory.
With the setting go.alternateTools, vscode-go lets us specify an alternate path for the tools used by the extension (i.e. dlv). I tried to configure that option for mockgen but it didn't change anything. My guess is that it does not work because vscode-go runs mockgen through gopls.generate; it does not run mockgen directly. But this is just a guess.
Below is the error I get if I don't have a mockgen binary in my $PATH:
[Info - 5:44:18 PM] 2021/08/08 17:44:18 xxxxxxx.go:19: running "mockgen": exec: "mockgen": executable file not found in $PATH
operation="generate"
Does anyone have any idea?
Edit: see @Zyl's comment there for a very good alternative.
