💨

VSCodeで`Failed to find the go binary in either GOROOT() `とエラーが出たら

2023/09/24に公開

このエラーが出るとGO言語の補完などができなくなる

環境

M1 Mac
VsCode
拡張機能: Go

解決方法

  1. VsCode設定ページで検索バーにGo:Gopathと入力する
  2. Go: Gopath
    Specify GOPATH here to override the one that is set as environment variable. The inferred GOPATH from workspace root overrides this, if go.inferGopath is set to true.の所にsettings.jsonで編集というリンクがあるのでクリックする
  3. settings.jsonが開くので"go.gopath": ""があるか確認する
  4. ターミナルでgo env GOPATHを実行して、出てきたパスを"go.gopath": ""の中に入力する
  5. VsCode設定ページで検索バーにGo: Gorootと入力する
  6. Go: Gorootsettings.jsonで編集というリンクがあるのでクリックする
  7. settings.jsonが開くので"go.goroot": ""があるか確認する
  8. ターミナルでgo env GOROOTを実行して、出てきたパスを"go.goroot": ""の中に入力する
  9. 無事解決
GitHubで編集を提案

Discussion