简体   繁体   English

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

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

I have godef installed via我通过以下方式安装了 godef

go get github.com/rogpeppe/godef

I have emacs go-mode installed, and the following exports in my .bashrc:我安装了 emacs go-mode,并在我的 .bashrc 中导出了以下内容:

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

godef is found in the sense that godef 的意义在于

godef -h # appears to work.

As in:如:

$ 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

When I run Cc Cd in a file in my emacs session, which should be calling a godef-describe function per当我在 emacs 会话中的文件中运行Cc Cd时,它应该调用godef-describe函数

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

I expect:我预计:

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.

Cool, all set.酷,一切就绪。 But when I try to use Cc Cd in a go file, I get:但是当我尝试在 go 文件中使用 Cc Cd 时,我得到:

Could not run godef binary

I can run it on the command line, and it appears properly defined.我可以在命令行上运行它,并且它的定义正确。 What's happening?发生了什么?

I find:我发现:

M-x godoc

// then
godoc: OSReadDir // for example

Produces生产

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

Which suggests to me that even though godef and godoc are found in an ordinary shell, there may be some path issue within emacs?这向我表明即使 godef 和 godoc 是在普通 shell 中找到的,但 emacs 中可能存在一些路径问题? How can I check or fix?我该如何检查或修复?

It's this again:又是这个:

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

If you launch emacs from the Ubuntu launcher, it doesn't load .bashrc.如果您从 Ubuntu 启动器启动 emacs,它不会加载 .bashrc。

You have to open a terminal, and call你必须打开一个终端,然后打电话

$ emacs

The emacs that pops up will have inherited your .bashrc from your shell.弹出的 emacs 将从你的 shell 继承你的 .bashrc。

在此处输入图片说明

~/.emacs.d/init.el ~/.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