Go: x/tools/cmd/guru: better help for implements

Created on 18 Apr 2017  Â·  7Comments  Â·  Source: golang/go

I'm trying to find all interfaces in the standard library that implement io.Reader or are called NewDecoder. I thought guru would be able to help with this but I was unable to figure out how to use it correctly.

  • guru help implements displays the generic help text.

  • guru implements -h or guru implements help print:

    $ guru implements -h
    guru: bad position syntax "-h"
    
  • guru implements -scope github.com/golang/go/src/... io.Reader prints simply:

    $ guru implements -scope github.com/golang/go/src/... io.Reader
    Run 'guru -help' for more information.
    

Reading the help text more carefully now, I see that I'm supposed to pass a filename and a line number as the position argument. This is a little confusing, I think, since other "implements" tools (dominikh/implements, "go oracle") said that this was a drop in replacement, and neither of them required filenames or line numbers, I don't think.

Maybe I am an idiot and maybe I should read more carefully but I wasn't able to find examples of successful usage when searching Google, and I wasn't able to get it to work, and it's possible that other users are having the same problems.

Tools

Most helpful comment

I read your quote. The problem is that other tools not designed to be
used from text editors now say "this is deprecated, use guru" but guru is a
poor fit for their use cases.

On Tue, Apr 18, 2017 at 15:19 stemar94 notifications@github.com wrote:

Seems like you didn't even read my quote, guess I found where the issue
is...

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.

User manual: http://golang.org/s/using-guru

Was listed in the guru -help page.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/golang/go/issues/20024#issuecomment-295000721, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAOSI0zeGqu19Q6Zmn6BtOwOHV1vLzjlks5rxTcGgaJpZM4NAd3w
.

>

--
Kevin Burke
925.271.7005 | kev.inburke.com

All 7 comments

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.

User manual: http://golang.org/s/using-guru

Was listed in the guru -help page.

I saw that link and it's also unhelpful for the purpose described in the ticket, since the only described usage for "implements" is a GIF of highlighting text in a text editor

Seems like you didn't even read my quote, guess I found where the issue is...

## _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.

User manual: http://golang.org/s/using-guru

Was listed in the guru -help page.

I read your quote. The problem is that other tools not designed to be
used from text editors now say "this is deprecated, use guru" but guru is a
poor fit for their use cases.

On Tue, Apr 18, 2017 at 15:19 stemar94 notifications@github.com wrote:

Seems like you didn't even read my quote, guess I found where the issue
is...

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.

User manual: http://golang.org/s/using-guru

Was listed in the guru -help page.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/golang/go/issues/20024#issuecomment-295000721, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAOSI0zeGqu19Q6Zmn6BtOwOHV1vLzjlks5rxTcGgaJpZM4NAd3w
.

>

--
Kevin Burke
925.271.7005 | kev.inburke.com

So that's then the fault of those tool maintainers or isn't it?

I think it's a good idea to improve the help here, or make the tool able to support passing in type names, or line and column numbers rather than file byte offsets. The command help doesn't describe the supported formats either.

Regardless of who's fault it is, it's confusing to people who are trying to use Go if various documents are pointing them at guru and guru doesn't solve their problem, so I think it would be appropriate to improve the documentation to reduce that confusion.

Regardless, this StackOverflow answer helped me: https://stackoverflow.com/a/31759333/1037465

It turns out that the local godoc -http=":8080" -analysis="type" command also enables searching for implementations (the online documentation doesn't) and you can do it from the Web browser.

screen shot 2017-10-01 at 18 04 17

I'd rather be able to type guru implements io.ReadSeeker though.

Correction: guru requires an offset instead of a line number.

Was this page helpful?
0 / 5 - 0 ratings