Closed
Description
For a simple main.go file:
package main
type Fooer interface {
Foo() string
}
type Int int
func (Int) Foo() string {
return "foo"
}
func main() {
}
When I run an implements query with the cursor over Fooer
, I get reasonable output:
$ guru -json implements main.go:#40
{
"type": {
"name": "github.com/zmb3/foo.Fooer",
"pos": "/Users/zbergquist/src/github.com/zmb3/foo/main.go:3:6",
"kind": "interface"
},
"to": [
{
"name": "github.com/zmb3/foo.Int",
"pos": "/Users/zbergquist/src/github.com/zmb3/foo/main.go:7:6",
"kind": "basic"
}
],
"method": {
"name": "func (Fooer).Foo() string",
"pos": "/Users/zbergquist/src/github.com/zmb3/foo/main.go:4:2"
},
"to_method": [
{
"name": "method (Int) Foo() string",
"pos": "/Users/zbergquist/src/github.com/zmb3/foo/main.go:9:12"
}
]
}
However, when the cursor is moved a few bytes to the right (over interface
) the output looks much different:
$ guru -json implements main.go:#50
{
"type": {
"name": "interface{Foo() string}",
"pos": "-",
"kind": "interface"
},
"to": [
{
"name": "github.com/zmb3/foo.Fooer",
"pos": "/Users/zbergquist/src/github.com/zmb3/foo/main.go:3:6",
"kind": "interface"
},
{
"name": "github.com/zmb3/foo.Int",
"pos": "/Users/zbergquist/src/github.com/zmb3/foo/main.go:7:6",
"kind": "basic"
}
],
"from": [
{
"name": "github.com/zmb3/foo.Fooer",
"pos": "/Users/zbergquist/src/github.com/zmb3/foo/main.go:3:6",
"kind": "interface"
}
]
}
It seems like guru
is now identifying the selection as an anonymous interface and not the type declaration for the Fooer
interface.
I'm finding the behavior in the latter case to be difficult to build tooling around, mostly because:
- The
type.name
field is long and hard to read for anything but the most simple interfaces - The extra
to
entry makes it seem like there is an extra interface in the program - The
type.pos
field is no longer populated