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

Goto Definition, Hover, Signature Help does not work for net package #442

Closed
Aukstkalnis opened this issue Aug 19, 2016 · 11 comments
Closed

Comments

@Aukstkalnis
Copy link

Windows 7 x86
VSCode 1.4.0
Go 0.6.43

When mouse is crossed on function than I should see function preview like this:

image

However, when I do this to net library functions I do see Loading.. for a blink of an eye and no preview is shown.

Also, ATL+F12 does not work on this library.

@lukehoban
Copy link
Member

Could you provide a more complete example of the problem?

@Aukstkalnis
Copy link
Author

Example Program:
package main

import "net"

func main() {
net.Listen("tcp","192.168.8.119:7000");
}

And when I write net.Listen(
I should see parameters that I should see like:
image
But with net library there is no list and when I cross with mouse on Listen word I see loading and it disappears in less then a second and I can not see definition of that function.

@jameshartig
Copy link

VSCode 1.6.1
Go 0.6.47

I'm having the same issue. It shows "Loading..." when hovering over net functions and won't let me Go To Definition on net functions. I turned on the developer console and don't see any errors or related messages in there.

@ramya-rao-a
Copy link
Contributor

This is an issue with godef itself.

rogpeppe/godef#48

#599

@leaxoy
Copy link
Contributor

leaxoy commented Nov 8, 2016

May be we can use gogetdoc instead both godef and godoc.
Use gogetdoc -json option we have five properties of name, import, decl, doc, pos.
For example:
{"name":"Now","import":"time","decl":"func Now() Time","doc":"Now returns the current local time.\n","pos":"/usr/local/opt/go/libexec/src/time/time.go:777:6"}
Which give us pos for godef's work, and doc and decl for godoc's work.
So in some way, godef tool is useless.

@leaxoy
Copy link
Contributor

leaxoy commented Nov 8, 2016

export function definitionLocation(document: vscode.TextDocument, position: vscode.Position, includeDocs = true): Promise<GoDefinitionInformtation> {
    return new Promise<GoDefinitionInformtation>((resolve, reject) => {
        let wordAtPosition = document.getWordRangeAtPosition(position);
        let offset = byteOffsetAt(document, position);
        let gogetdoc = getBinPath('gogetdoc');
        let p = cp.execFile(gogetdoc, ['-json', '-pos=' + document.fileName + ':#' + offset.toString()], {}, (err, stdout, stderr) => {
            try {
                if (err && (<any>err).code === 'ENOENT') {
                    promptForMissingTool('gogetdoc');
                }
                if (err) return resolve(null);
                let goDocInfomation: GoDocInfomation = JSON.parse(stdout.toString());
                if (goDocInfomation.doc === 'A concurrent prime sieve\n') {
                    return resolve({
                        file: null,
                        line: 0,
                        column: 0,
                        signature: ['builtin keyword'],
                        doc: goDocInfomation.doc
                    });
                }
                let match = /(.*):(\d+):(\d+)/.exec(goDocInfomation.pos);
                if (!match) {
                    return resolve({
                        file: null,
                        line: 0,
                        column: 0,
                        signature: goDocInfomation.decl.split('\n'),
                        doc: goDocInfomation.doc
                    });
                }
                let [_, file, line, col] = match;
                return resolve({
                    file: file,
                    line: +line - 1,
                    column: +col - 1,
                    signature: goDocInfomation.decl.split('\n'),
                    doc: goDocInfomation.doc
                });
            } catch (e) {
                reject(e);
            }
        });
        p.stdin.end(document.getText());
    });
}

interface

interface GoDocInfomation {
    name: string;
    import: string;
    decl: string;
    doc: string;
    pos: string;
}

@ramya-rao-a ramya-rao-a changed the title The preview function parameters from net library not works Goto Definition, Hover, Signature Help does not work for net package Nov 20, 2016
@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Nov 21, 2016

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, reload/restart VS Code and that should fix this issue.

@zgiber
Copy link

zgiber commented Dec 3, 2016

@ramya-rao-a Thank you for the fix, however simply performing the steps described in the comment does not solve the problem in my case. It makes all the Goto/Peek Definition, Hover info and Signature Help functions stop working. Perhaps there is something I've missed? Go Extension 0.6.50, VSCode Version 1.7.2 (1.7.2).

@ramya-rao-a
Copy link
Contributor

@zgiber What version of Go are you using? Can you share the output of go version ?
If you are using Go from source, then yes in Go extension 0.6.50, Goto/Peek Definition, Hover info and Signature Help features stopped working. The newest update 0.6.51 has the fix for it

@zgiber
Copy link

zgiber commented Dec 4, 2016

@ramya-rao-a I'm using go version go1.7.4 darwin/amd64, not from source, but from archive. The Go plugin is now version 0.6.51. After adding the line: "go.docsTool": "gogetdoc", to user settings and restarting VSCode, Goto/Peek definition, Hover info, Signature stopped working. Removing the line restored the usual functionalities, but then the original issue (no tooltip on net package's functions) remains.

@ramya-rao-a
Copy link
Contributor

@zgiber Since what you are seeing is specific to gogetdoc, I opened a new issue to track it #679. Lets continue the discussion in that thread

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 24, 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

6 participants