找不到 asdf 安装的 "go" 二进制文件

Cannot find "go" binary installed by asdf

使用 asdf 安装 Go 并尝试打开 Go 项目后出现以下错误。

Failed to find the "go" binary in either。GOROOT() or PATH(/usr/bin:/bin:/usr/sbin:/sbin). Check PATH, or Install Go and reload the window.

我通过重新启动 VSCode 解决了这个问题。

另一个人也建议在 this issue 中进行修复,而我不需要这样做。

  1. Shift + Cmd + P
  2. 搜索:“打开设置”并选择“打开设置(JSON)”
  3. 运行 go env 并复制 GOROOT 值(在我的例子中是 /opt/homebrew/Cellar/go/1.17.1/libexec)。
  4. 添加新记录到 settings.json:
"go.goroot": "Copied/GOROOT/path",

在我的例子中是:

"go.goroot": "/opt/homebrew/Cellar/go/1.17.1/libexec"