doudao1369 2017-06-20 11:46
浏览 79
已采纳

Elisp调用具有不同结果的Go代码

This question is on the back of this GitHub issue, when executing godef-jump on code on some named imports (but not all), it fails with the error that godef: no declaration found for <the gx.thing we're godef-jump'ing>.

Basically I'm a bit stuck with where to go next in my debugging. I've changed the code in go-mode.el to use the -debug flag with godef, and the outputs are different, from CLI is successful like this:

$ godef -f main.go gx.GetPackageRoot
/home/tomato/ipfs/src/github.com/whyrusleeping/gx/gxutil/pm.go:50:6

Whereas in Emacs it fails with the godef: no declaration found for <the gx.thing we're godef-jump'ing> error.

With the debug flag enabled, CLI:

$ godef -debug -t -f /home/tomato/ipfs/src/github.com/whyrusleeping/gx/main.go -o 565
2017/06/20 13:29:14 exprType tuple:false pkg: *ast.SelectorExpr gx.GetPackageRoot [
2017/06/20 13:29:14 exprType tuple:false pkg: *ast.Ident gx [
2017/06/20 13:29:14 exprType tuple:false pkg: *ast.ImportSpec gx "github.com/whyrusleeping/gx/gxutil" [
2017/06/20 13:29:14 ] -> 0x0, Type{package "" *ast.ImportSpec gx "github.com/whyrusleeping/gx/gxutil"}
2017/06/20 13:29:14 ] -> 0xc420276140, Type{package "" *ast.ImportSpec gx "github.com/whyrusleeping/gx/gxutil"}
2017/06/20 13:29:14 member Type{package "" *ast.ImportSpec gx "github.com/whyrusleeping/gx/gxutil"} 'GetPackageRoot' {
2017/06/20 13:29:14 } -> &{func GetPackageRoot 0xc4203ac3f0 <nil> <nil>}
2017/06/20 13:29:14 exprType tuple:false pkg: *ast.Ident GetPackageRoot [
2017/06/20 13:29:14 exprType tuple:false pkg: *ast.FuncType func() (string, error) [
2017/06/20 13:29:14 ] -> 0x0, Type{type "" *ast.FuncType func() (string, error)}
2017/06/20 13:29:14 ] -> 0xc420138140, Type{func "" *ast.FuncType func() (string, error)}
2017/06/20 13:29:14 ] -> 0xc420138140, Type{func "github.com/whyrusleeping/gx/gxutil" *ast.FuncType func() (string, error)}
/home/tomato/ipfs/src/github.com/whyrusleeping/gx/gxutil/pm.go:50:6
GetPackageRoot func() (string, error)

Emacs:

2017/06/20 13:31:18 exprType tuple:false pkg: *ast.SelectorExpr gx.GetPackageRoot [
2017/06/20 13:31:18 exprType tuple:false pkg: *ast.Ident gx [
2017/06/20 13:31:18 exprType tuple:false pkg: *ast.ImportSpec gx "github.com/whyrusleeping/gx/gxutil" [
2017/06/20 13:31:18 ] -> 0x0, Type{package "" *ast.ImportSpec gx "github.com/whyrusleeping/gx/gxutil"}
2017/06/20 13:31:18 ] -> 0xc4201fde50, Type{package "" *ast.ImportSpec gx "github.com/whyrusleeping/gx/gxutil"}
2017/06/20 13:31:18 member Type{package "" *ast.ImportSpec gx "github.com/whyrusleeping/gx/gxutil"} 'GetPackageRoot' {
2017/06/20 13:31:18 } -> <nil>
2017/06/20 13:31:18 ] -> 0x0, Type{bad "" <nil> }
godef: no declaration found for gx.GetPackageRoot

I've used strace to confirm that the expected binary is being called with the expected flags.

I guess the next thing I should do is find out where/how this 2017/06/20 13:29:14 member Type{package "" *ast.ImportSpec gx "github.com/whyrusleeping/gx/gxutil"} 'GetPackageRoot' { line of output from the debugs is, since it is the next line of debug that differs, but maybe somebody has some better ideas or can already see what's going on here.

  • 写回答

1条回答 默认 最新

  • dqyy38265 2017-06-20 14:21
    关注

    The issue was that Emacs was not aware of my GOPATH environment variable, this was resolved by adding this to exec-path-from-shell-copy-envs in my initialization files, like so:

    (exec-path-from-shell-copy-envs '("PATH" "GOPATH"))
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器