💨
VSCodeで`Failed to find the go binary in either GOROOT() `とエラーが出たら
このエラーが出るとGO言語の補完などができなくなる
環境
M1 Mac
VsCode
拡張機能: Go
解決方法
- VsCode設定ページで検索バーに
Go:Gopath
と入力する -
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で編集
というリンクがあるのでクリックする -
settings.json
が開くので"go.gopath": ""
があるか確認する - ターミナルで
go env GOPATH
を実行して、出てきたパスを"go.gopath": ""
の中に入力する - VsCode設定ページで検索バーに
Go: Goroot
と入力する -
Go: Goroot
のsettings.jsonで編集
というリンクがあるのでクリックする -
settings.json
が開くので"go.goroot": ""
があるか確認する - ターミナルで
go env GOROOT
を実行して、出てきたパスを"go.goroot": ""
の中に入力する - 無事解決
Discussion