Closed2
goの拡張機能入れたのにシンタックスハイライト表示してくれない

goの拡張機能入れてるけどシンタックスハイライト入れてくれないので拡張機能一回アンインストールしてインストールしてみたら
Error loading workspace: You are outside of a module and outside of $GOPATH/src. If you are using modules, please open your editor to a directory in your module. If you believe this warning is incorrect, please file an issue: https://github.com/golang/go/issues/new.

上のエラーは
現在開いているプロジェクトまたはディレクトリが Go モジュールなのか $GOPATH/src 内にあるかを判断できないぽかったので
この記事で見た、src配下はモジュールモードにしてくれるモードに変更した
$ go env -w GO111MODULE=auto
ちゃんとシンタックスハイライト表示してくれるようになった
このスクラップは2023/11/18にクローズされました