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 内にあるかを判断できないぽかったので
https://zenn.dev/spiegel/articles/20210223-go-module-aware-mode#環境変数-go111module-によるモードの切り替え
この記事で見た、src配下はモジュールモードにしてくれるモードに変更した

$ go env -w GO111MODULE=auto

ちゃんとシンタックスハイライト表示してくれるようになった

このスクラップは2023/11/18にクローズされました