-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/tools/gopls: typeDefinition should support jumping to type of function/method's single return value? #38589
Comments
That seems reasonable to me. Thanks for reporting. |
Consider the case: type myFunc func(int) string
var foo myFunc
bar := foo() If you run go-to-type-definition on "foo()" it should take you to the myFunc definition, not the "string" return value. Most go-to-thingy commands operate on an identifier, not an expression, so this behavior would be inconsistent. |
I think it's a good idea to support functions/methods with two return values when the second one is either func GetX() (x X, err error)
// or
func GetX() (x X, ok bool) are more common than this one func GetX() X The implementation won't become much more difficult. What do you think? |
…urn values Support typeDefinition for functions with a single return value and double return values if the second one is either bool or error: * func foo() X * func foo() (X, bool) * func foo() (X, error) Fixes golang/go#38589
Change https://golang.org/cl/313093 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Consider the following example:
With the cursor within the
GetX()
call inside the call tofmt.Println()
, a jump to definition correctly takes us to the definition ofGetX()
.However, a goto type definition results in an error:
Given
GetX()
returns a single value in this instance this could be made to work. Indeed having go to type definition work in the case a function/method returning a single value seems useful.Thoughts?
What did you expect to see?
Go to type definition from the cursor position described above to jump to the definition of
X
.What did you see instead?
An error.
cc @stamblerre
FYI @leitzler
The text was updated successfully, but these errors were encountered: