Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
x/tools/gopls: go to the definition of the only non-test interface implementation #40584
(Currently using v0.4.4 with Go 1.14.6.)
When exploring new codebases I often go to the definition of a method just to find out that the method is actually a part of an interface. I then use the “find implementations” action to find the implementation. Often there is only one non-test implementation.
So, I would like to request a new action which would act like the current one, but go to the definition of the only non-test interface implementation if there is only one, or to the definition of the interface if there are several.
I've been wanting this myself for find-implementations and find-references as well. In particular, I want a way to only return non-test results for find-implementations and find-references.
By default it should work the way it does now since that is most correct and what people expect. That means we need an option to control gopls behavior. There is precedent for options in find-references with the "includeDeclaration", but there is no option for excluding tests.
I think in the short term this functionality would need to be implemented in the LSP client (i.e. the editor). For the long term we can open an LSP feature request to add a "excludeTests" option to find-implementations and find-references and see what they think. I looked briefly but didn't see any existing issues.