Jay Taylor's notes

back to listing index

Using Go Guru

[web search]
Original source (docs.google.com)
Tags: golang go tooling ide guru docs.google.com
Clipped on: 2017-02-07

Using Go Guru
Image (Asset 1/7) alt= 
 Share
File
Edit
View
Tools
Help
 
 
 
 
View only
 
 
To enable screen reader support, press shortcut Ctrl+Alt+Z. To learn about keyboard shortcuts, press shortcut Ctrl+slash.
Using​ ​Go​ ​Guru: 
an​ ​editor-integrated​ ​tool​ ​for​ ​navigating​ ​Go​ ​code 
http://golang.org/s/using-guru 
Alan​ ​Donovan 
Created​ ​August​ ​25,​ ​2013 
Last​ ​updated​ ​July​ ​8,​ ​2016 
 
This​ ​document​ ​shows​ ​how​ ​to​ ​use​ ​the​ ​​Go​ ​Guru​,​ ​an​ ​editor-integrated​ ​tool​ ​that​ ​answers​ ​the​ ​kinds​ ​of 
questions​ ​that​ ​come​ ​up​ ​all​ ​the​ ​time​ ​during​ ​a​ ​typical​ ​day​ ​of​ ​Go​ ​programming.​ ​​ ​For​ ​example: 
 
Where​ ​is​ ​this​ ​identifier​ ​declared? 
Where​ ​are​ ​all​ ​the​ ​references​ ​to​ ​this​ ​declaration? 
What​ ​are​ ​the​ ​fields​ ​and​ ​methods​ ​of​ ​this​ ​this​ ​expression? 
What​ ​is​ ​the​ ​API​ ​of​ ​this​ ​package? 
Which​ ​concrete​ ​types​ ​implement​ ​this​ ​interface? 
What​ ​are​ ​the​ ​possible​ ​callees​ ​of​ ​this​ ​dynamic​ ​call? 
What​ ​are​ ​the​ ​possible​ ​callers​ ​of​ ​this​ ​function? 
Where​ ​might​ ​a​ ​value​ ​sent​ ​on​ ​this​ ​channel​ ​be​ ​received? 
 
The​ ​guru​ ​tool​ ​is​ ​editor-agnostic,​ ​so​ ​it​ ​brings​ ​many​ ​of​ ​the​ ​features​ ​of​ ​a​ ​heavyweight​ ​IDE​ ​to​ ​your 
existing​ ​editor.​ ​​ ​In​ ​addition​ ​it​ ​provides​ ​some​ ​advanced​ ​static​ ​analysis​ ​features​ ​not​ ​found​ ​in​ ​any 
IDE. 
 
[GopherCon​ ​2016​ ​talk​ ​on​ ​the​ ​Go​ ​Guru:​ ​​https://www.youtube.com/watch?v=ak97oH0D6fI​] 
 
The​ ​guru​ ​supports​ ​about​ ​a​ ​dozen​ ​different​ ​kinds​ ​of​ ​query.​ ​​ ​To​ ​issue​ ​a​ ​query,​ ​position​ ​your​ ​cursor 
(or​ ​text​ ​selection)​ ​on​ ​the​ ​name​ ​or​ ​expression​ ​of​ ​interest,​ ​then​ ​invoke​ ​the​ ​desired​ ​guru​ ​command 
through​ ​your​ ​editor's​ ​interface.​ ​​ ​Depending​ ​on​ ​the​ ​editor,​ ​this​ ​might​ ​be​ ​a​ ​menu​ ​selection​ ​or​ ​a 
keyboard​ ​shortcut.​ ​​ ​For​ ​most​ ​queries,​ ​the​ ​results​ ​will​ ​appear​ ​in​ ​a​ ​new​ ​buffer​ ​in​ ​your​ ​editor.​ ​​ ​See 
the​ ​screen​ ​capture​ ​videos​ ​below​ ​for​ ​examples. 
 
 
 
Setting​ ​up 
 
Download​ ​and​ ​build​ ​the​ ​guru​ ​tool​ ​and​ ​install​ ​it​ ​somewhere​ ​on​ ​your​ ​​$PATH​. 
 
$​ ​go​ ​get​ ​​ ​​ ​golang.org/x/tools/cmd/guru 
$​ ​go​ ​build​ ​golang.org/x/tools/cmd/guru 
$​ ​mv​ ​guru​ ​$(go​ ​env​ ​GOROOT)/bin​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​(for​ ​example) 
$​ ​guru​ ​-help 
Go​ ​source​ ​code​ ​guru. 
Usage:​ ​guru​ ​[flags]​ ​<mode>​ ​<position> 
... 
 
For​ ​many​ ​guru​ ​queries,​ ​the​ ​only​ ​necessary​ ​configuration​ ​is​ ​the​ ​​$GOPATH​​ ​environment​ ​variable​ ​that 
defines​ ​the​ ​workspace​ ​of​ ​packages. 
 
Although​ ​guru​ ​is​ ​a​ ​command-line​ ​tool,​ ​it​ ​is​ ​intended​ ​to​ ​be​ ​executed​ ​by​ ​your​ ​editor.​ ​​ ​The​ ​output​ ​of 
most​ ​guru​ ​queries​ ​is​ ​a​ ​list​ ​of​ ​diagnostics,​ ​each​ ​prefixed​ ​by​ ​a​ ​source​ ​file​ ​name,​ ​line​ ​number,​ ​and 
column​ ​number,​ ​similar​ ​to​ ​the​ ​diagnostic​ ​output​ ​of​ ​a​ ​typical​ ​compiler.​ ​Most​ ​editors​ ​can​ ​display 
compiler​ ​output​ ​in​ ​a​ ​buffer​ ​so​ ​that​ ​clicking​ ​on​ ​a​ ​diagnostic​ ​opens​ ​the​ ​relevant​ ​source​ ​file​ ​at​ ​the 
right​ ​position. 
 
Consult​ ​the​ ​documentation​ ​specific​ ​to​ ​your​ ​editor​ ​to​ ​complete​ ​the​ ​installation. 
 
Editor 
Documentation 
Acme 
https://github.com/davidrjenni/A​​ ​​ ​​ ​​ ​(define​ ​new​ ​commands) 
https://github.com/mjibson/aw​​ ​​ ​​ ​​ ​(serves​ ​output​ ​to​ ​web​ ​browser) 
https://github.com/mpl/gofinder​​ ​​ ​​ ​​ ​(using​ ​Acme​ ​window) 
Atom.io 
Toggle screen reader support
Add to My Drive