Open arifmahmudrana opened 2 years ago
Interface stub generation is provided by https://github.com/josharian/impl. There is some discussion around supporting package-local interface in josharian/impl#14. Do you get the expected result if you use the unqualified interface identifier for the input (i.e. "c categoryResponse CategoryRepository" instead of "c categoryResponse repo.CategoryRepository" )?
Looks like this is the old way of generating interface stub (that's based on impl
tool, not gopls
)
If you generate the stub using the gopls's code action (see below), do you still observe the same issue?
)
(note: this gopls-based workflow currently requires some hints. For example, in my screenshot, I gave a dummy var _ I = &c{}
. Another way is to start using c
where I
is expected.)
I still feel this gopls-based workflow is harder to find compared to the original command-style implementation. In https://github.com/golang/go/issues/37537 and https://github.com/golang/go/issues/37537#issuecomment-1131750277 we discussed possibility of supporting this workflow. I know it was blocked on work for better known packages/interfaces discovery. @marwan-at-work @findleyr Is there an open issue to follow up the progress?
Interface stub generation is provided by https://github.com/josharian/impl. There is some discussion around supporting package-local interface in josharian/impl#14. Do you get the expected result if you use the unqualified interface identifier for the input (i.e. "c categoryResponse CategoryRepository" instead of "c categoryResponse repo.CategoryRepository" )?
@jamalc I get this error
Cannot stub interface: unrecognized interface: CategoryRepository
Looks like this is the old way of generating interface stub (that's based on
impl
tool, notgopls
)If you generate the stub using the gopls's code action (see below), do you still observe the same issue?
)
(note: this gopls-based workflow currently requires some hints. For example, in my screenshot, I gave a dummy
var _ I = &c{}
. Another way is to start usingc
whereI
is expected.)I still feel this gopls-based workflow is harder to find compared to the original command-style implementation. In golang/go#37537 and golang/go#37537 (comment) we discussed possibility of supporting this workflow. I know it was blocked on work for better known packages/interfaces discovery. @marwan-at-work @findleyr Is there an open issue to follow up the progress?
@hyangah Yes this works.
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
* Run `go version` to get version of Go from _the VS Code integrated terminal_. - go1.16.5 linux/amd64 * Run `gopls -v version` to get version of Gopls from _the VS Code integrated terminal_. - v0.9.1 * Run `code -v` or `code-insiders -v` to get version of VS Code or VS Code Insiders. - 1.69.2 * Check your installed extensions to get the version of the VS Code Go extension - v0.35.1 * Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > `Go: Locate Configured Go Tools` command. -
Generate interface stubs
When generate interface stubs for interface in same file it adds the package name for parameter. When generate interface stubs for interface in same file it shouldn't add the package name.
Screenshots or recordings
https://user-images.githubusercontent.com/2046796/180152669-40dc5cc2-977a-4c8c-91bb-a09ce9d76de2.mp4