Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

"Go to Definition" not working for structs #459

Closed
apkrieg opened this issue Aug 29, 2016 · 9 comments
Closed

"Go to Definition" not working for structs #459

apkrieg opened this issue Aug 29, 2016 · 9 comments

Comments

@apkrieg
Copy link

apkrieg commented Aug 29, 2016

This is a feature my colleagues and I use very often when programming in Go (and other languages). I'm not sure if this is already implemented and I have not enabled it or if it is simply missing.

@apkrieg
Copy link
Author

apkrieg commented Aug 29, 2016

Correction, it seems this feature does work, but only for functions and not structs, fields, or interfaces. It should work for all types.

@ramya-rao-a ramya-rao-a changed the title "Go to Definition" not working "Go to Definition" not working for structs Aug 30, 2016
@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Aug 30, 2016

@lukehoban @zmb3 @abarisain Would integrating gogetdoc help here?
#87 (comment)

@abarisain
Copy link
Contributor

I think so !

@abarisain
Copy link
Contributor

Actually, it already works on my gogetdoc2 branch.

@apkrieg if you can do a small repro file that fails with the current version, I could confirm that gogetdoc fills this gap

@apkrieg
Copy link
Author

apkrieg commented Aug 30, 2016

@abarisain I tried it with three libraries:

  • github.com/satori/go.uuid
  • github.com/go-sql-driver/mysql
  • github.com/go-gl/glfw/v3.2/glfw

The only library I can use "Go to Definition" with is github.com/satori/go.uuid.

// Testing "Go to Definition"
package main

import (
    "github.com/satori/go.uuid"
    "github.com/go-sql-driver/mysql"
    "github.com/go-gl/glfw/v3.2/glfw"
)

var (
    // Works
    id uuid.UUID
    // Does not work
    db mysql.Config
)

func main() {
    // Works
    uuid.NewV4()
    // Does not work
    db.FormatDSN()
    // Does not work
    glfw.CreateWindow(128, 128, "Title", nil, nil)
}

@abarisain
Copy link
Contributor

Thanks for the repro, I got the same results on my windows computer on the master branch.

While it is a little slower than godef, the abarisain/vscode-go gogetdoc2 branch handles this correctly.
Couldn't try glfw, only MySQL, since I don't have gcc installed on this box

@nochso
Copy link
Contributor

nochso commented Oct 12, 2016

The current implementation fails mostly because of these few lines: https://github.com/Microsoft/vscode-go/blob/8c7d2d364059d4ed30d8931476306c6b9ef011bc/src/goDeclaration.ts#L66-L70

From what I can tell, it looks for func Name.. even for structs. However the output of godoc for structs looks like func (t *Type) Name..

@ramya-rao-a
Copy link
Contributor

Is this still a problem? I tried the example at https://gobyexample.com/interfaces which uses structs and interfaces. I was able to use the Go to Definition feature without any problem

I am running VS Code 1.6.1 with Go extension 0.6.45 in Mac OS X

@ramya-rao-a
Copy link
Contributor

In the latest update of the Go extension (0.6.50), we now support the use of gogetdoc for Goto/Peek Definition, Hover info and Signature Help features. Add "go.docsTool": "gogetdoc" to your setting to enable the use of gogetdoc, restart VS Code and that should fix this issue.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants