godef
godef copied to clipboard
godef by expression not working with go/packages
I think this works without go/packages:
- Create
hello.go:
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
go mod init.- Run
godef -f hello.go fmt.Println. - You get the error:
godef: Offset -1 was not a valid identifier
try godef -t -f hello.go -o 43, you may get
xxx/hello.go:3:8
import (fmt "fmt")
try
godef -t -f hello.go -o 43, you may getxxx/hello.go:3:8 import (fmt "fmt")
This is about the expression mode not working. Offset mode still works.
Mod is not supporting expression now, it uses https://godoc.org/golang.org/x/tools/go/packages to find definition.