gpt4 book ai didi

SublimeText 中的 Gofmt 插件未找到 GOPATH 错误

转载 作者:行者123 更新时间:2023-12-01 17:44:51 26 4
gpt4 key购买 nike

安装 gofmt 包后,我在 Sublime Text 中不断收到此错误:

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 显然没有被选中,有什么想法吗?

最佳答案

本文档中提到了在不同操作系统上设置变量的说明 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

enter image description here

关于SublimeText 中的 Gofmt 插件未找到 GOPATH 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58566612/

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