godef icon indicating copy to clipboard operation
godef copied to clipboard

Godef fails to locate local package files outside current working dir when using -i

Open DamnWidget opened this issue 9 years ago • 0 comments

When godef is used with the -i flag it fails to find definitions in other files from the buffer local package if it is located in the file system in a directory different than the current working directory. How to replicate:

Create a couple of directories:

mkdir -p godef_issue/pkg

Add the following as godef_issue/pkg/one.go:

package pkg

import "fmt"

func hello() {
    fmt.Println(definedInTwo)
}

This as `godef_issue/pkg/two.go':

package pkg

const definedInTwo = "Hello, I am defined in two.go"

Go to godef_issue and execute:

$ godef -f pkg/one.go 'definedInTwo'
pkg/two.go:3:7
$ cat pkg/one.go | godef -i 'definedInTwo'
parseLocalPackage error: no more package files found
godef: no declaration found for definedInTwo

I am providing a simple PR to fix it

DamnWidget avatar Jul 25 '16 15:07 DamnWidget