This is a creation in Article, where the information may have evolved or changed.
Godef can print out the symbols in the Go source code, many integrated development tools have integrated it, and provide Go to Definition commands and shortcut keys, can quickly jump to the method and the declaration of the variable place, very convenient.
For example, I used the vscode-go, provided such a function, but at present Godef has a bug, is not able to jump net to the standard library package method definition, the bug has been submitted to GitHub: #18, about June when the bug was found, It is unclear why the author did not fix, in fact, someone had provided a modified pull request earlier. The reason for this bug is that Godef did not handle the "C" library properly.
I am here to record the modification method, you can manually modify the compilation godef.
Locate the parser file (go/parser/parser.go) under the Godef folder and add a judgment in line 1970.
1234567 |
Name, err: = P.pathtoname (littostring (path), filepath. Dir (filename))if"C" { //The following three lines are new to modify this bug new added line if"" "C" "C"} if "" { |
This way your godef will work properly.
In addition, if you upgrade to Go1.7 found that the Vscode Code autocomplete function does not work, you can try to execute in the terminal gocode close , this bug can refer to: 441.