在安装了gofmt包之后,我一直在崇高文本中得到这个错误:
Traceback (most recent call last):
File "/Users/abrahma/Library/Application Support/Sublime Text 3/Installed Packages/Gofmt.sublime-package/gofmt.py", line 257, in run_formatter
formatter = Formatter(view)
File "/Users/abrahma/Library/Application Support/Sublime Text 3/Installed Packages/Gofmt.sublime-package/gofmt.py", line 166, in __init__
self.cmds = [Command(cmd, self.view, self.window) for cmd in cmds]
File "/Users/abrahma/Library/Application Support/Sublime Text 3/Installed Packages/Gofmt.sublime-package/gofmt.py", line 166, in <listcomp>
self.cmds = [Command(cmd, self.view, self.window) for cmd in cmds]
File "/Users/abrahma/Library/Application Support/Sublime Text 3/Installed Packages/Gofmt.sublime-package/gofmt.py", line 77, in __init__
self.window)
File "/Users/abrahma/Library/Application Support/Sublime Text 3/Packages/golangconfig/all/golangconfig.py", line 227, in subprocess_info
raise exception
golangconfig.EnvVarError: The following environment variable is currently unset: GOPATH我的文件有以下内容:
"env" : {
"GOPATH" : "/Users/abrahma/git/go",
"GOROOT" : "/usr/local/Cellar/go/1.12.7/libexec",
}(这与我的终端上的go env输出相匹配)
我还有一个golang.sublime-settings文件,其内容如下:
{
"env" : {
"GOPATH" : "/Users/abrahma/git/go",
"GOROOT" : "/usr/local/Cellar/go/1.12.7/libexec",
}
}因此,出于某种原因,上面提到的GOPATH显然没有被采纳,有什么好的解释吗?
发布于 2019-10-26 05:16:34
由于@lbu的建议,我意识到我需要在我的登录shell (在我的例子中是~/.zprofile)中存在这一点,而且它现在运行得很好。
发布于 2020-07-03 11:22:22
本文档https://github.com/golang/sublime-config/blob/master/docs/user.md中提到了在不同操作系统上设置变量的说明。
我在macOs中使用Sublime3和GolangConfig,并遇到了同样的错误。在golang.sublime-settings中设置下面的内容帮助我解决了这个问题。
{
"PATH": "/Users/suryapandian/go/bin",
"GOPATH": "/Users/suryapandian/go"
}注意:在下面附上图片以定位golang.sublime-settings

https://stackoverflow.com/questions/58566612
复制相似问题