x/tools/gopls: Go generate fails when net/http is imported in source file #51063
Labels
FrozenDueToAge
gopls
Issues related to the Go language server, gopls.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
gopls version
go env
What did you do?
I created a wrapper around http.Client in order to mock the client in my code using dependency injection. When I try to generate the mock for my interface, it fails. However, if I remove "import "net/http" and all references to it from my wrapper code, I can generate the mock. Here is the very simple wrapper that fails to generate the mock file:
Running
go generate
against this results in errors.However, if I change the code to this, to remove net/http just as a test, it generates the mock file perfectly well...
Another oddity is, if I do generate the mock successfully using the altered code, if I try to regenerate it, that also fails. If I first delete the generated mock file, however, then I can regenerate it.
What did you expect to see?
Properly generated mock files for my interface
What did you see instead?
The errors shown above in context of the code examples, and in attached logs
Editor and settings
Logs
gopls.log
The text was updated successfully, but these errors were encountered: