繁体   English   中英

在 go-mode emacs 会话中找不到 Godef

[英]Godef not being found in a go-mode emacs session

我通过以下方式安装了 godef

go get github.com/rogpeppe/godef

我安装了 emacs go-mode,并在我的 .bashrc 中导出了以下内容:

export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

godef 的意义在于

godef -h # appears to work.

如:

$ godef -h
usage: godef [flags] [expr]
  -A    print all type and members information
  -a    print public type and member information
  -acme
        use current acme window
  -debug
        debug mode
  -f string
        Go source filename
  -i    read file from stdin
  -json
        output location in JSON format (-t flag is ignored)
  -o int
        file offset of identifier in stdin (default -1)
  -t    print type information

当我在 emacs 会话中的文件中运行Cc Cd时,它应该调用godef-describe函数

https://github.com/dominikh/go-mode.el

我预计:

Integration with godef

    godef-describe (C-c C-d) to describe expressions
    godef-jump (C-c C-j) and godef-jump-other-window (C-x 4 C-c C-j) to jump to declarations
    This requires you to install godef via go get github.com/rogpeppe/godef.

酷,一切就绪。 但是当我尝试在 go 文件中使用 Cc Cd 时,我得到:

Could not run godef binary

我可以在命令行上运行它,并且它的定义正确。 发生了什么?

我发现:

M-x godoc

// then
godoc: OSReadDir // for example

生产

godoc: /bin/bash: go: command not found

这向我表明即使 godef 和 godoc 是在普通 shell 中找到的,但 emacs 中可能存在一些路径问题? 我该如何检查或修复?

又是这个:

https://askubuntu.com/questions/1045712/emacs-launched-from-favorites-doesnt-read-bashrc

如果您从 Ubuntu 启动器启动 emacs,它不会加载 .bashrc。

你必须打开一个终端,然后打电话

$ emacs

弹出的 emacs 将从你的 shell 继承你的 .bashrc。

在此处输入图片说明

~/.emacs.d/init.el

(setq exec-path (append exec-path '("/root/go/bin")))

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM