【问题标题】:failed to load view for file:///D:/Go: err: go resolves to executable in current directory (.\go): stderr:无法为 file:///D:/Go 加载视图:错误:go 解析为当前目录 (.\\go) 中的可执行文件:stderr:
【发布时间】:2022-10-17 23:17:55
【问题描述】:

我在 Windows 10 上使用 vim 和 emacs,通过 MSYS 安装 go install golang.org/x/tools/gopls@latest

但是 emacs eglot 和 nvim lspconfig 显示:

[eglot] Connected! Server `gopls' now managing `go-mode' buffers in project `Go'.
[eglot] Server reports (type=4): Loading packages...
[eglot] Server reports (type=3): Error loading packages: err: go resolves to executable in current directory (.\go): stderr: 
[eglot] Server reports (type=1): Error loading workspace folders (expected 1, got 0)
failed to load view for file:///D:/Go: err: go resolves to executable in current directory (.\go): stderr: 

【问题讨论】:

  • 你确定 Go 在你的 MSYS PATH 变量上吗?

标签: go language-server-protocol gopls


【解决方案1】:

我相信你必须设置变量 GOPATH 和 GOBIN。我不使用 Windows,在 Linux 中,您可以编辑 .profile 并添加:

export GOPATH="$HOME/go"
export GOBIN="$GOPATH/bin"

我还设置了以下内容:

go env -w "GOBIN=<full path to go binaries>"

我使用 eglot 并解决了问题。 希望能帮助到你!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-02
    • 2017-04-23
    • 2018-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多