golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.83k stars 17.51k forks source link

x/tools/cmd/guru: better help for implements #20024

Closed kevinburke closed 9 hours ago

kevinburke commented 7 years ago

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.

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.

stemar94 commented 7 years ago

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.

kevinburke commented 7 years ago

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

stemar94 commented 7 years ago

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.

kevinburke commented 7 years ago

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

stemar94 commented 7 years ago

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

a-h commented 6 years ago

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.

wenjianhn commented 5 years ago

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

adonovan commented 9 hours ago

guru was deleted in https://github.com/golang/go/issues/65880; closing as obsolete. Incidentally, gopls has the same issue.