简体   繁体   中英

Godef not being found in a go-mode emacs session

I have godef installed via

go get github.com/rogpeppe/godef

I have emacs go-mode installed, and the following exports in my .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 -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

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:

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? How can I check or fix?

It's this again:

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.

You have to open a terminal, and call

$ emacs

The emacs that pops up will have inherited your .bashrc from your shell.

在此处输入图片说明

~/.emacs.d/init.el

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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