gpt4 book ai didi

在 go-mode emacs session 中找不到 Godef

转载 作者:IT王子 更新时间:2023-10-29 02:01:36 26 4
gpt4 key购买 nike

我已经通过安装 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 session 中的一个文件中运行 C-c C-d 时,它应该调用一个 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 文件中使用 C-c C-d 时,我得到:

Could not run godef binary

我可以在命令行上运行它,它看起来定义正确。发生了什么事?

我发现:

M-x godoc

// then
godoc: OSReadDir // for example

生产

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

这对我来说意味着即使在普通 shell 中可以找到 godef 和 godoc,但在 emacs 中可能存在一些路径问题?我该如何检查或修复?

最佳答案

又是这个:

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

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

你必须打开一个终端,然后调用

$ emacs

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

关于在 go-mode emacs session 中找不到 Godef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51642744/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com