go - 在 go-mode emacs 会话中找不到 Godef
问题描述
我通过安装 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
当我C-c C-d
在我的 emacs 会话中运行一个文件时,它应该调用一个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。
推荐阅读
- sql - Sql 逻辑运算符.. AND & OR 组合
- node.js - 在 Elastic Beanstalk 上使用 Yarn 安装包
- java - 425 建立连接失败
- r - R分布在多个值列中
- python - 在 python 中存储不连续数字范围的最佳方法是什么?
- javascript - 当我有一个 unorderlist 时,Readmore 不起作用
- javascript - 未定义的不是对象 this.props.navigation(onOpened 通知)
- neo4j - 使用余弦相似度计算两个文档之间的相似度(neo4j)
- android-studio - 无法在android studio中打开模拟器
- vb.net - VB.NET为datagridview中的多列设置宽度