godef
godef copied to clipboard
godef: no declaration found when using dot import syntax
It works when the code looks like this.
file: main.go
package main
import (
"fmt"
"time"
)
func main() {
ti := time.Now()
fmt.Println(ti)
}
➜ godef -f=./main.go -o=68
/usr/local/Cellar/go/1.5/libexec/src/time/time.go:781:6
but it failed when the code change to this:
file: main.go
package main
import (
"fmt"
. "time"
)
func main() {
ti := Now()
fmt.Println(ti)
}
➜ godef -f=./main.go -o=65
parseLocalPackage error: no more package files found
godef: no declaration found for Now
This is a known issue with godef. In general, dot imports are a bad idea, but this should probably be fixed some time.
For testing dot imports are pretty useful, for example ginkgo and goconvey use it to good effect.
It's also useful when putting tests in a separate package, e.g. package foo_test
Any plans to fix this?