-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.
Milestone
Description
What version of Go are you using (go version
)?
$ go version go version go1.20.7 darwin/amd64
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GOHOSTARCH="amd64" GOHOSTOS="darwin"
What did you do?
I tried to use vscode to "find all references", "find all implementations", "go to definition" of an function type alias embedded in a struct. vscode is unable to find it. vscode uses gopls
so I believe it is gopls
that is at fault.
What did you expect to see?
I expected to be taken to the method that the type alias references.
What did you see instead?
"go to definition" took me to the method that the function alias was itself part of (where it was being called from).
Load the following program into vscode. right click on the commented function call and try to find what actually would get called.
package main
import (
"context"
"fmt"
)
type cmdable func(ctx context.Context, arg string) string
type client struct {
cmdable
}
func (c *client) init() {
c.cmdable = c.Process
}
func (c *client) Process(ctx context.Context, arg string) string {
return arg
}
func (c cmdable) DoIt(ctx context.Context, arg string) string {
return c(ctx, arg) // really?!?
}
func main() {
var c client
c.init()
fmt.Println(c.DoIt(context.Background(), "wtf"))
}
Metadata
Metadata
Assignees
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.