Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/cmd/guru: no way to find functions which are assignable to (match the signature of) a function type #25165

Open
a-h opened this issue Apr 29, 2018 · 3 comments · May be fixed by golang/tools#37

Comments

@a-h
Copy link
Contributor

@a-h a-h commented Apr 29, 2018

If I define a function type:

type Printer func(s string)

And a function which accepts a Printer:

type Print(s string, p Printer) {
  p(s)
}

I'd like to be able to use guru to find methods which satisfy the Printer type's signature. I'd also be able to find any matching functions for an anonymous function signature too (e.g. var x func(s string)).

guru is often used to provide text editor features. Having the ability to discover implementations would allow being able to place a caret on p Printer, select Find implementations from the text editor options, then view a list of possible implementations to use.

I've put together an example of how this might work at https://gist.github.com/a-h/dd48a97aba7c07f988aac8e529dadf6d

(See Stackoverflow question at https://stackoverflow.com/questions/50059956/how-do-i-find-implementations-of-a-function-type/50086309#50086309)

@gopherbot gopherbot added this to the Unreleased milestone Apr 29, 2018
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Apr 30, 2018

@stamblerre

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented May 2, 2018

This would be a nice feature and could probably become part of the existing "implements" query. If you'd like to contribute the code you wrote, feel free to send out a review. Otherwise, I'd be happy to look into adding this.

@a-h a-h linked a pull request that will close this issue May 26, 2018
@a-h

This comment has been minimized.

Copy link
Contributor Author

@a-h a-h commented Jun 22, 2018

Does anyone have any interest in reviewing this on Gerrit? https://go-review.googlesource.com/c/tools/+/114800

@gopherbot gopherbot added the Tools label Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.